Using Java from .Net (C#) with JNI

  • Thread starter Sebastien Roeckel
  • Start date
S

Sebastien Roeckel

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
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top