c++ -> JNI on a SuSe Linux - Can't seem to find my Java files

Hi all,

I have been playing around with the JNI for a bit now on my windows box and got it working fine and all :) Now, however, I need to port my stuff to a SuSe linux, and I have started out really basic - just trying to start the JVM too see how that went... badly, would be the answer to that question, in case you were wondering.

I made a really simple textbook example (alot of those, when searching this forum - and searched, I have) to just create myself a JVM. I am not even daring to actually try and find any classes, call methods or anything as bold as that yet.

My example compiles fine, but when I run the program I get this error message:

"Can't find class java.lang.NoClassDefFoundError. Invalid class path ?"

Now, please note, this is not the actual NoClassDefFoundError exception being thrown here, but looks to me as if the system wanted to throw that exception object, but couldn't even find the object to throw at me ;-)

This leads me to believe that there's is something *really basic* wrong with my Java setup here. I can run "java" just fine from the commandline, but it occurs to me, that the JVM, when invoked via the JNI, can't find it's own stuff.

Any suggestion what needs to be done here?

I can post code if that helps, but I doubt that is the problem - as it is really textbook stuff and I can get this stuff to work on Windows. I think the problem is "external" to my code, as it happens before I even try to use the JVM. Maybe some env vars needs to be set? I have manually tried to export a CLASSPATH variable, just to see if that helped - I even tried adding full path to core.jar in my "-Djava.class.path" property ;-)

I have tried removing and adding the Java RPM's again (Java version 1.4.1 FYI) to no avail aswell.

[1820 byte] By [Rune_Espensena] at [2007-10-1 23:17:13]
# 1

Hi,

As you hv started working on JNI. You must know the following things.

1. If you want to work on Windows they must hv to hv a .dll file of your c/C++ program while on linux you should have .so file. i.e. shared object file.

2. On Linux you should set LD_LIBRARY_PATH environment variable to your the path where you have stored your .so file.

Let me know if you do have above things and still getting error.

- Uday

P.S. You will find help on internet abt How to make dll's and .so file?

UdayTashildara at 2007-7-15 14:05:32 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2
Hello and thank you for taking an interest in my problem :)I do have that environment variable set up allready. (Failing to do so, will result in the error that it "cannot find jsig in libjava.so/libjsig.so") - so that is not my problem, I am afraid.
Rune_Espensena at 2007-7-15 14:05:32 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 3
may be u hv set LD_LIBRARY_PATH environment variable to multiple directories. Check it and if yes then try to set it to a directory where ur only required .so/.dll file exist.- Uday
UdayTashildara at 2007-7-15 14:05:32 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 4
LD_LIBRARY_PATH points to only this one directory in the filesystem, nothing else :-/
Rune_Espensena at 2007-7-15 14:05:32 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 5
I think I just made a small break through - setting -Xbootclasspath to point to the core.jar, seems to resolve some of this - perhaps I need to manually set set this... will play abit around with this and post my findings :)Thanks for your help so far :)
Rune_Espensena at 2007-7-15 14:05:32 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 6
Ok, for some reason, the JVM didn't know it's own class files location (as indicated by the error message). The way to specify it to them was, obviously as usual once you find a solution to a problem, to let the JVM know the path via the -Xbootclasspath.Problem solved c",)
Rune_Espensena at 2007-7-15 14:05:32 > top of Java-index,Java HotSpot Virtual Machine,Specifications...