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
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