JNI and

Discussion in 'Java' started by yshamama@magicsoftware.com, Jun 14, 2005.

  1. Guest

    Hi all

    I am using java from C++ using JNI calls
    the JVM created when the C++ application is started
    and destroyed just before it stop running

    While my C++ app is running I am creating new class in java
    and I want to use them using JNI calls
    but the I can't found the class because its not in the classpath

    what should I do ???

    thanks
    , Jun 14, 2005
    #1
    1. Advertising

  2. On 14 Jun 2005 08:50:26 -0700, wrote:
    > While my C++ app is running I am creating new class in java and I
    > want to use them using JNI calls but the I can't found the class
    > because its not in the classpath


    Specify a classpath argument when you create the JVM.

    /gordon

    --
    [ do not email me copies of your followups ]
    g o r d o n + n e w s @ b a l d e r 1 3 . s e
    Gordon Beaton, Jun 14, 2005
    #2
    1. Advertising

  3. Guest

    Re: JNI and classpath

    Hi

    Thanks for your quick reply but my problem is that my classes is in a
    jar file
    and I don't have the location of the jar when I'm creating the JVM.
    I get is location only after I alreay create the JVM.
    I need a way to load the classes in that jar after I create the JVM
    even if the jar file is not the classpath.

    Thanks
    , Jun 15, 2005
    #3
  4. Chris Uppal Guest

    Re: JNI and classpath

    wrote:

    > [..] but my problem is that my classes is in a jar file
    > and I don't have the location of the jar when I'm creating the JVM.


    Then your problem is /exactly/ the same as it would be if you were working in
    Java directly, nothing whatever to do with JNI. The solution is also exactly
    the same: create your own classloader (probably a java.net.URLClassLoader) and
    use that to load code from the jar file.

    (Actually you do have another option using JNI -- you could extract the
    classfiles from the JAR file and then inject the bytecode into the JVM directly
    using the DefineClass() function in JNI. Offhand, I can't think of any good
    reason for wanting to do it that way, though.)

    -- chris
    Chris Uppal, Jun 15, 2005
    #4
    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. Alex Hunsley

    IBM's JNI fails where Sun's JNI works

    Alex Hunsley, Nov 3, 2003, in forum: Java
    Replies:
    4
    Views:
    837
    Alex Hunsley
    Nov 4, 2003
  2. Pasturel Jean-Louis

    Porting JNI Windows under JNI LINUX + Wine ?

    Pasturel Jean-Louis, Feb 29, 2004, in forum: Java
    Replies:
    5
    Views:
    892
    Pasturel Jean-Louis
    Mar 3, 2004
  3. vasanth
    Replies:
    0
    Views:
    2,663
    vasanth
    Jan 25, 2005
  4. vasanth
    Replies:
    0
    Views:
    610
    vasanth
    Jan 25, 2005
  5. bgabrhelik
    Replies:
    0
    Views:
    787
    bgabrhelik
    Sep 29, 2009
Loading...

Share This Page