eclipse library path - driving me nuts!

M

MileHighCelt

I have several *.dll and a couple of classes that I need to use in my
java application. I have created a jar that contains the dll's, and
have imported the classes as their own library. When I run my tests,
I get the error :

Can't find library something.so/something.dll
java.lang.UnsatisfiedLinkError: no something in java.library.path

I have printed out the library path and it doesn't reference the jars:
java.library.path = C:\Program
Files\Java\j2re1.4.2\bin;.;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS;C:\Program

Files\cvsnt;

I thought just importing both the jar and classes would mean they were
included? How do I get the dll's to be picked up at runtime?

Oh yea, I am using Eclipse 3.1 and JDK 1.4.2

Thank you, I really appreciate any help you can offer.
 
V

Vova Reznik

MileHighCelt said:
I have several *.dll and a couple of classes that I need to use in my
java application. I have created a jar that contains the dll's, and
have imported the classes as their own library. When I run my tests,
I get the error :

Can't find library something.so/something.dll
java.lang.UnsatisfiedLinkError: no something in java.library.path

I have printed out the library path and it doesn't reference the jars:
java.library.path = C:\Program
Files\Java\j2re1.4.2\bin;.;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS;C:\Program

Files\cvsnt;

I thought just importing both the jar and classes would mean they were
included? How do I get the dll's to be picked up at runtime?

Oh yea, I am using Eclipse 3.1 and JDK 1.4.2

Thank you, I really appreciate any help you can offer.
Right click on your Project->Properties->Java Build Path->Libraries->Add
External Jars
And/Or
Run-> Tab "Class Path"
 
M

MileHighCelt

I added the jar to the Library External Jars and also did
Run -> Run - > Classpath -> User Entries > "Add external JARs"

and I get the same error. I see this jar being referenced in the
"java.class.path" but not the "java.library.path" which is odd because
I would think being in the library path is sufficience. I can view
the jar and confirm that all the files I need are in there.

Argh!
 
V

Vova Reznik

MileHighCelt said:
I added the jar to the Library External Jars and also did
Run -> Run - > Classpath -> User Entries > "Add external JARs"

and I get the same error. I see this jar being referenced in the
"java.class.path" but not the "java.library.path" which is odd because
I would think being in the library path is sufficience. I can view
the jar and confirm that all the files I need are in there.

Argh!
All ext. jars included by:
Project->Properties->Java Build Path->Add external JARs
shown as java.class.path

java.library.path shows everything from Path
 
M

MileHighCelt

I really appreciate your help, and I hope you can help me with this, I
feel I am close but doing one minor thing wrong. I added these to my
test:

System.out.println("java.library.path = " +
System.getProperty("java.library.path"));
System.out.println("java.ext.dirs = " +
System.getProperty("java.ext.dirs"));
System.out.println("java.class.path = " +
System.getProperty("java.class.path"));

And I get the following:

java.library.path = C:\Program Files\Java\j2re1.4.2\bin;.;
C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32;
C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Novell\ZENworks\;
C:\Program Files\cvsnt;
java.ext.dirs = C:\Program Files\Java\j2re1.4.2\lib\ext
java.class.path =
C:\eclipse\workspace\TaxWareTest\classes;C:\eclipse\plugins\org.junit_3.8.1\junit.jar;C:\eclipse\workspace\TaxWareTest\lib\taxware.jar;/c:/eclipse/plugins/org.eclipse.jdt.junit_3.1.0/junitsupport.jar;/c:/eclipse/plugins/org.eclipse.jdt.junit.runtime_3.1.0/junitruntime.jar

I just can't see why taxware.jar is added to the java.class.path but
not the java.library.path, and even then why it isn't found...

Thank you again for any advice you can send my way.
 
M

MileHighCelt

I have just realized that the problem is not the jar could not be
found, but that the dll files are compressed inside the jar file,
preventing them from being used properly. I added the path to the dll
files to my windows path and that worked. Now I need to find a way to
package them up in a way that they can be deployed but not compressed

Thank you again for your help, sorry it was such a easy mistake!
 
R

Roedy Green

I thought just importing both the jar and classes would mean they were
included? How do I get the dll's to be picked up at runtime?

Instead of import, use the menu item with a name like "edit library
path". I found it much more tractable.
 
S

Steve Sobol

MileHighCelt said:
I added the jar to the Library External Jars and also did
Run -> Run - > Classpath -> User Entries > "Add external JARs"

and I get the same error. I see this jar being referenced in the
"java.class.path" but not the "java.library.path" which is odd because
I would think being in the library path is sufficience. I can view
the jar and confirm that all the files I need are in there.

Argh!

java.library.path is where the DLLs are.

The JARs need to be on the classpath.
 
P

pkriens

Eclipse is based on OSGi (http://www.osgi.org). You can include native
code in the JAR file (compressed is ok) but you must include a
Bundle-NativeCode header in your manifest. This Bundle Native code
header specifies meta information about the native code: language, os,
version, etc. This information can be used to add multiple
version/variations of your native code library to a single JAR; this
significantly eases deployment problems.

You can find the OSGi specification at: http://www.osgi.org/download

Check out the section about Native Code.

The OSGi runtime (Eclipse in this case) must extracts the native code
from the JAR file (anywhere) and tell the Java Vm where it can be
found.
 
M

MileHighCelt

I guess I don't follow what you are saying. If I need to distribute
these dll and lib files either locally or to production, I have to use
the OSGI specification? I was hoping that I could just bundle them up
in a jar and fiqure out some way to put them in the path.

I tried jar'ing them up uncompressed, and that didn't work either. I
wonder if it needs to be a CAB file since its a Windows platform?
 
P

pkriens

The class loader of the class that uses the native code will try to
locate the library. As said, this is very conveniently handled by
OSGi/Eclipse; the library is automatically extracted from the JAR file
and placed in a managed area.

The system CANNOT read the DLL from the JAR. If you want to put it on
the library path, you must somehow extract it on the target system and
place it there. Note that you will then also be responsible for any
updates you might make and versioning. All these things are handled
rather nicely by the OSGi Framework.

So yes, it might cost you some time to figure it out once, but it will
clearly be easier in the long run. You can mail me offline with some
details and then I can show you how to construct the JARs and
manifests.

Kind regards,

Peter Kriens
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top