Using Java from .Net (C#) with JNI

Discussion in 'Java' started by Sebastien Roeckel, Apr 1, 2004.

  1. Hello

    I have a java class and I want to call it from a .Net project (in C#).

    What I have done for now:
    - I have written C++ code (by using Visual Studio 6.0) to call the java
    class by using the JNI: this is working. This code has been included in a
    dll.
    - When I am calling the dll from a .Net project, the following exception is
    raised "Object not set to an instance of an object"

    When I call this DLL from an executable written in C++ (built with Visual
    Studio 6): it is working.
    When I call another DLL (which does not use JNI) from the .Net project it is
    also working.

    The problem comes from running the JNI in .Net.


    I finally found that the JNI function JNI_CreateJavaVM (for initializing
    the JVM and the environment) returns null objects (instead of initialized
    pointers to the JVM and to the environment) when the DLL is called from a
    ..Net project.


    Does anybody know why the JVM is not correctly initialized when the DLL is
    called from .Net code ? What can I do to make it work ? (probably by
    modifying the init arguments passed to the JNI_CreateJavaVM function ??)


    Thank you for your help


    Sebastien
     
    Sebastien Roeckel, Apr 1, 2004
    #1
    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:
    869
    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:
    937
    Pasturel Jean-Louis
    Mar 3, 2004
  3. vasanth
    Replies:
    0
    Views:
    2,754
    vasanth
    Jan 25, 2005
  4. vasanth
    Replies:
    0
    Views:
    635
    vasanth
    Jan 25, 2005
  5. bgabrhelik
    Replies:
    0
    Views:
    872
    bgabrhelik
    Sep 29, 2009
Loading...

Share This Page