Solved

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

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
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 learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

706 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now