Dear programmers,
I am having some trouble in order to determine the OS used by the JVM. I would
like to load some libraries but i don't know the system that is running it.
I would like to do something like:
static{
if(Linux)
System.loadLibrary("libHello.so");
if(Windows)
System.loadLibrary("Hello.dll");
}
Can you help me, please?
thanks a lot,
Marcelo
Danno - 23 Jan 2006 05:54 GMT
Too much work
http://java.sun.com/j2se/1.4.2/docs/guide/jni/spec/design.html#wp679
package pkg;
class Cls {
native double f(int i, String s);
static {
System.loadLibrary("pkg_Cls");
}
}
Java will convert it automatically depending on the system. You may
have to do something else if you have code specific to Unix based OSs.
Gordon Beaton - 23 Jan 2006 06:47 GMT
> I would like to do something like:
>
[quoted text clipped - 4 lines]
> System.loadLibrary("Hello.dll");
> }
This will fail in both cases. Juse specify the base name of the
library, i.e.:
System.loadLibrary("Hello");
The JVM will load "libHello.so" or "Hello.dll", whichever is
appropriate for the platform.
/gordon

Signature
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e