JNI Question.  C/C++ to Java (creating a JVM)

Posted on 2002-03-19
Last Modified: 2010-08-05
I am having a problem creating a JVM from C/C++.  I am getting an error code of -1 when I call JNI_CreateJavaVM(...) API from C.

I am using jdk1.1.3 ->
I am setting:

JDK1_1InitArgs vm_args;
vm_args.version = JNI_VERSION_1_2;

I think the problem might have to do with my classpath.
vm_args.classpath = ???

I'm not sure what my class path should be.  I tried many different things.  I put my .class java file in the c:\ directory and set the classpath to c:\, but it didn't work.

Does anyone have any suggestions!

Thank you.  jcast17

Question by:jalgazi
LVL 86

Accepted Solution

jkr earned 200 total points
ID: 6880683
The "classpath" usually is "%SYSTEMROOT%\\java\\classes", so you could

char acClassPath [ MAX_PATH];

sprintf ( acClassPath, "%s\\java\\classes", getenv ( "SYSTEMROOT"));

(error checking omitted for brevity)

Author Comment

ID: 6880719
Could you please be a little more specific.

Do I need to include rt.jar... I tried copying the above  code you gave me, but I am still unsuccesful
I am don't know much when it comes to this stuff.

I have seem examples that say I should include.


thanks, jcast17.
LVL 86

Expert Comment

ID: 6880815
LVL 11

Expert Comment

ID: 6955432
Dear jalgazi

I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity,  I will suggest to accept


comment(s) as an answer.

If you think your question was not answered at all, you can post a request in Community support (please include this link) to refund your points. The link to the Community Support area is:


Expert Comment

ID: 6979106
Force accepted

** Mindphaser - Community Support Moderator **

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Find boost header files using gnu make (MinGW) on Win 7 11 86
trigs fail! I thought I knew how to do trignometry 3 65
Beginner to Unreal Engine 4 5 79
max float value 3 39
When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question