User defined class problem

A

aurengo

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
 
J

John Currier

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top