User defined class problem

Discussion in 'Java' started by aurengo@wanadoo.fr, Aug 10, 2005.

  1. Guest

    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
     
    , Aug 10, 2005
    #1
    1. Advertising

  2. John Currier Guest

    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
     
    John Currier, Aug 11, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Oodini
    Replies:
    1
    Views:
    1,787
    Keith Thompson
    Sep 27, 2005
  2. Angel Tsankov
    Replies:
    1
    Views:
    872
    Victor Bazarov
    Apr 5, 2006
  3. Replies:
    1
    Views:
    509
    Sion Arrowsmith
    Jul 10, 2008
  4. Keith Thompson

    Re: __STDC_IEC_559__ (defined or !defined ?)

    Keith Thompson, Aug 17, 2010, in forum: C Programming
    Replies:
    0
    Views:
    446
    Keith Thompson
    Aug 17, 2010
  5. Alok
    Replies:
    3
    Views:
    258
Loading...

Share This Page