JNI Probs!!!

hi,

having some real headaches trying to compile my C++ code while linking to 'jvm.dll',

this is the command i issue at the dos prompt:

"cl -Ic:\jdk1.3\include -Ic:\jdk1.3\include\win32 -MT invoker.cpp -link c:\jdk1.3\jre\bin\classic\jvm.dll"

then the output is as follows:

"Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 80x86

Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

invoker.cpp

Microsoft (R) Incremental Linker Version 6.00.8168

Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

/out:invoker.exe

c:\jdk1.3\jre\bin\classic\jvm.dll

invoker.obj

c:\jdk1.3\jre\bin\classic\jvm.dll : fatal error LNK1136: invalid or corrupt file"

obviously the most important thing here is the last bit:

"c:\jdk1.3\jre\bin\classic\jvm.dll : fatal error LNK1136: invalid or corrupt file"

don't really know why that's happening, i've been following the online tutorial on the sun site (and i've had to make alot of changes to what's there because i'm using jdk1.3 and the docs seem a bit out of date)

any suggestions or a pointer to some more up to date documentation would be greatly appreciated!!!!

many thanks and kindest regards in advance,

dug.

[1326 byte] By [dugg_ee] at [2007-9-26 8:04:15]
# 1
PLEASE HELP!!!!this seems to be a common thread.....dug.
dugg_ee at 2007-7-1 18:25:03 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2

Don't link against the .DLL file - link against the .LIB file.

you will find it in JDK_HOME\lib

e.g. on my system it is in F:\jdk1.4\lib\jvm.lib

That being said, I'm having problems at run time, because the jvm.dll is not in the path that is normally searched for DLLs, if I put my .exe file in the same directory as jvm.dll everything works. I can't move jvm.dll because then it won't find the rest of the java runtime.

What is the proper solution to that one?

SWP at 2007-7-1 18:25:03 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 3

> That being said, I'm having problems at run time,

> because the jvm.dll is not in the path that is

> normally searched for DLLs, if I put my .exe file in

> the same directory as jvm.dll everything works. I

> can't move jvm.dll because then it won't find the rest

> of the java runtime.

>

> What is the proper solution to that one?

You have to set the path to the DLL. do a set path:

set path=%path%;F:\jdk1.4\lib\jvm.dll or wherever

because during runtime the system is going to look for the executables and libraries in the normal path.

hope that helps!

ssst at 2007-7-1 18:25:03 > top of Java-index,Java HotSpot Virtual Machine,Specifications...