Reputation: 19778
I know it's possible to load a DLL (Windows library) in java.
And I know that a compiled java program runs anywhere..
Can a java program that loads a DLL run in a Unix environment ? (if the DLL file is present there)
Upvotes: 1
Views: 2346
Reputation: 159754
No. A DLL runs native Windows instructions that are not compatible with a UNIX operating system. However shared libraries (.so) can be accessed using JNI.
To ensure a portable "Write once run anywhere" model, calls to native libraries should be avoided in favor of a pure Java implementation.
Upvotes: 3
Reputation: 645
It is possible to load the DLL in unix indeed. However many dlls use the windows API which is not available on UNIX. You must also check for copyright issues that you may encounter doing that. Native library access is possible using JNI. But this (loading DLL in unix) is not a supported and reliable configuration.
To give you a brief answer and a short advice: the answer is no and the advice is to not waste your time doing this.
Upvotes: 0
Reputation: 21
No. You can't take a Windows PE/COFF DLL and stick it in a Unix environment, it just won't work. (Unless you're talking about Cygwin/MSYS)
You will have to compile the library for the target system and use that.
Upvotes: 1
Reputation: 272207
I would be very surprised. The DLL (provided it's native) will be built with OS and platform-specifics.
Upvotes: 1