Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > User defined class problem

Reply
Thread Tools

User defined class problem

 
 
aurengo@wanadoo.fr
Guest
Posts: n/a
 
      08-10-2005
Hi

For teaching purpose, I develop a Java image processing program.
It includes the possibility of creating, compiling and executing java
"scripts" at runtime.
The java instructions are encapsulated between
"public class " + sourceName + " extends GenScr { "
and
" }"
(GenScr is a root class which defines some shortcuts)
I call javac which compiles this source and puts the compiled "script"
class in some directory.
To run the class, I use a ClassLoader and Method.invoke of the method
"main" of my new class.
All this is classical and works fine ; the "scrips" code can access
every static function of the program.

Problems however arise when a "script" class try to access the static
main method of another "script" class
For the compilation, there is no problem since javac is aware of where
the script classes are, thanks to the -classpath option.
But when I try to execute I get a
"java.lang.reflect.InvocationTargetException" error.
I use MacOSX XCode which puts the jar file of the main program (Spah) in
a hidden directory (Spah.app/Contents/Ressource/Java). I tried to put
the new classes in this directory but I get the same error result.

The program which executes java (I dont know its name) is unable to find
the called "script" class.
Is there a way to tell it where to look for the newly created classes ?
Thanks for any help

 
Reply With Quote
 
 
 
 
John Currier
Guest
Posts: n/a
 
      08-11-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
<snip>
> Problems however arise when a "script" class try to access the static
> main method of another "script" class
> For the compilation, there is no problem since javac is aware of where
> the script classes are, thanks to the -classpath option.
> But when I try to execute I get a
> "java.lang.reflect.InvocationTargetException" error.
> I use MacOSX XCode which puts the jar file of the main program (Spah) in
> a hidden directory (Spah.app/Contents/Ressource/Java). I tried to put
> the new classes in this directory but I get the same error result.
>
> The program which executes java (I dont know its name) is unable to find
> the called "script" class.
> Is there a way to tell it where to look for the newly created classes ?


>From InvocationTargetException's javadocs:

InvocationTargetException is a checked exception that wraps
an exception thrown by an invoked method or constructor.

The wrapped exception (which you didn't mention) should give you a clue
on what's going wrong.

John
http://schemaspy.sourceforge.net

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: __STDC_IEC_559__ (defined or !defined ?) Keith Thompson C Programming 0 08-17-2010 04:36 PM
User-defined exception: "global name 'TestRunError' is not defined" jmike@alum.mit.edu Python 1 07-10-2008 12:37 PM
Using parenthesis with defined (#if defined(...)) Angel Tsankov C++ 1 04-05-2006 10:00 PM
Nested Class, Member Class, Inner Class, Local Class, Anonymous Class E11 Java 1 10-12-2005 03:34 PM
#if (defined(__STDC__) && !defined(NO_PROTOTYPE)) || defined(__cplusplus) Oodini C Programming 1 09-27-2005 07:58 PM



Advertisments