Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Inline::Java and Can't locate object method "new" error
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: adam@eng.mc.xerox.com

Disclaimer: All views expressed
here have been proved to be my own.  [http://www.csh.rit.edu/~adam/]


Report this thread to moderator Post Follow-up to this message
Old Post
Adam Stein
03-08-08 12:41 AM


Re: Inline::Java and Can't locate object method "new" error
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: adam@eng.mc.xerox.com

Disclaimer: All views expressed
here have been proved to be my own.  [http://www.csh.rit.edu/~adam/]


Report this thread to moderator Post Follow-up to this message
Old Post
Adam Stein
03-08-08 12:41 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL INLINE module archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 12:25 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.