I finally find the solution.  I actually didn't get any replies, but I'm
posting what I found in case somebody else has this problem in the
future.

It turned out to be that the Java code I was calling had a getResource()
call to open an ASCII file.  This was working fine when everything
(including the ASCII file) was put into a JAR file.  Didn't work when
calling it thru Inline::Java.  The code couldn't find the file and a
null exception occurred.  Replaced the getResource() with a
FileInputStream() to read the file from disk and everything worked
great.

On Fri, 2008-03-07 at 11:27 -0500, Adam Stein wrote:
> Just started using Inline::Java (v0.52) with Java v1.5.0_12.  Couldn't
> find a solution anywhere and my company blocks of anything useful in
> Google Groups.
> 
> I had no problem running the simple example given.  My problem starts
> when I try to reference other classes.  Given a small example:
> 
> ----Perl Code----
> use Cwd;
> 
> use Inline Java => <<'END_OF_JAVA_CODE', CLASSPATH => getcwd;
>     import my.java.app.here.MyOtherClass;
> 
>     class MyClass {
>       public MyClass() {
>           MyOtherClass myobj;
>       }
>     }
> END_OF_JAVA_CODE
> 
> my ($obj) = MyClass->new();
> ----Perl Code----
> 
> MyOtherClass.java is at 'my/java/app/here/MyOtherClass.java' relative to
> my current directory (hence the getcwd call to add to CLASSPATH).
> 
> This compiles fine.  When I run it, I get:
> 
> Can't locate object method "new" via package "MyClass" (perhaps you
> forgot to load "MyClass"?) at ./example line 13.
> 
> If I comment out the 'MyOtherClass myobj;' line, it works fine.  The
> only solution I found to this type of problem was when the person was
> using Inline::Java within a Perl package (which I'm not doing).
> 
> I would appreciate any hints, tips, URLs, ways to debug the problem,
> etc.
-- 
Adam Stein @ Xerox Corporation       Email: [EMAIL PROTECTED]
                                            
Disclaimer: All views expressed             
here have been proved to be my own.  [http://www.csh.rit.edu/~adam/]

Reply via email to