Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2002-03-19
5
Medium Priority
?
444 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 800 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

971 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