Solved

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

Posted on 2002-03-19
5
431 Views
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


0
Comment
Question by:jalgazi
5 Comments
 
LVL 86

Accepted Solution

by:
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)
0
 

Author Comment

by:jalgazi
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.

".;c:\\jdk1.3.1\\jre\\lib\\rt.jar;c:\\prog.class"


thanks, jcast17.
0
 
LVL 86

Expert Comment

by:jkr
ID: 6880815
0
 
LVL 11

Expert Comment

by:griessh
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

     "jkr"

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: http://www.experts-exchange.com/commspt/

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0
 
LVL 6

Expert Comment

by:Mindphaser
ID: 6979106
Force accepted

** Mindphaser - Community Support Moderator **
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

839 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