Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JNI question (javai.lib????) 1

Status
Not open for further replies.

brownie124

Programmer
Sep 19, 2002
61
0
0
US
Hi,

I have now seen a couple of examples for using the JNI to call a functions within a dll. In both samples the makefile said to link with javai.lib. I do not see that on my system anywhere. What is it? Do I really need it? If so, where do I get it?

Thanks,
- Brownie
 
Brownie, I am using Windows 2000, jdk1.3.1 and jdk1.4.2. I don't have the file either. I think it's not needed on Windows.

javai.lib is used on Solaris

I think Windows uses "...\jdk...\lib\jvm.lib". But I haven't used JNI myself, so I'm not sure.
 
Yes jvm.lib is the correct library to link for JNI.

-pete
 
brownie,
to use jni, you need to:-
1. compile your java class, Test.java -> Test.class
2. use javah.exe (should come with jdk) to create the h file
--> $javah.exe Test.class
3. This should create C/C++ header file.
4. You need to create the *.C/*.cpp file
5. build the dll
6. In java file, to load the library, use
System.loadLibrary("your dll")

7. make sure the dll is in \windows\system32 dir



~za~
You can't bring back a dead thread!
 
maxpower1 may be correct if your use of JNI is restricted to going from Java to C/C++, i am not 100% sure.

If you want to call back into the Java environment from C/C++ you need to link in jvm.lib. This is what i assumed you were needing since you posted the question in the first place.

-pete
 
you,re right pete. it is restricted to c/c++

~za~
You can't bring back a dead thread!
 
Guys, thanks for the help, I am all set. Have it working beautifully.
 
Hi,

I figured that you had to link jvm.lib but I am glad to be sure of that now because I was looking for javai.lib as well, but now at least I know that is not the solution to my problem. Does anybody have any idea why when I call JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args) it always returns 0 and the JVM instance is never created. I am new to JNI and I just want to create a simple install for my java applications and it looks like JNI is the best way to go. I'd really appreciate any help.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top