loadLibrary fails in linux

M

Mike

Hi

I'm trying to load Java3D library files from an arbitrary location.

In windows i use this code that works fine:

String fileSeparator = System.getProperty("file.separator");
String home = System.getProperty("user.home");
String path = home + fileSeparator + "Application Data" + fileSeparator
+ "Sun" + fileSeparator + "Java" + fileSeparator + "Deployment" +
fileSeparator + "ext";
System.setProperty("java.library.path", path);
System.loadLibrary("j3dcore-d3d");
System.loadLibrary("j3dcore-ogl");

Now i want to do the same in linux using this code but fails:

String fileSeparator = System.getProperty("file.separator");
String home = System.getProperty("user.home");
String path = home + fileSeparator + ".java" + fileSeparator +
"deployment" + fileSeparator + "ext";
System.setProperty("java.library.path", path);
System.loadLibrary("j3dcore-ogl");

It spawns this errror:

java.lang.UnsatisfiedLinkError:no j3dcore-ogl in java.library.path

I've made sure the libj3dcore-ogl.so file is actually there. Printing
out the java.library.path property seemingly reveals the correct path:
/home/mike/.java/deployment/ext
I've tried using
System.load("/home/mike/.java/deployment/ext/libj3dcore-ogl.so") instead
using an absolute path to no avail.
Does anyone know why this doesn't work in linux?

Thanx
Mike
 
E

Ewald Ertl

Hi,


Hi

I'm trying to load Java3D library files from an arbitrary location.

In windows i use this code that works fine:

String fileSeparator = System.getProperty("file.separator");
String home = System.getProperty("user.home");
String path = home + fileSeparator + "Application Data" + fileSeparator
+ "Sun" + fileSeparator + "Java" + fileSeparator + "Deployment" +
fileSeparator + "ext";
System.setProperty("java.library.path", path);
System.loadLibrary("j3dcore-d3d");
System.loadLibrary("j3dcore-ogl");

Now i want to do the same in linux using this code but fails:

String fileSeparator = System.getProperty("file.separator");
String home = System.getProperty("user.home");
String path = home + fileSeparator + ".java" + fileSeparator +
"deployment" + fileSeparator + "ext";
System.setProperty("java.library.path", path);
System.loadLibrary("j3dcore-ogl");

It spawns this errror:

java.lang.UnsatisfiedLinkError:no j3dcore-ogl in java.library.path

I've made sure the libj3dcore-ogl.so file is actually there. Printing
out the java.library.path property seemingly reveals the correct path:
/home/mike/.java/deployment/ext
I've tried using
System.load("/home/mike/.java/deployment/ext/libj3dcore-ogl.so") instead
using an absolute path to no avail.
Does anyone know why this doesn't work in linux?
I don't know how this is done in Java, but for C/C++ Applications it
is necessary
to set the environment variable LD_LIBRARY_PATH to the dynamic
libraries which should
be loaded.
Perhaps this is also necessary here.

HTH
Ewald
 
M

Menno Holscher

Mike said:
java.lang.UnsatisfiedLinkError:no j3dcore-ogl in java.library.path

I've made sure the libj3dcore-ogl.so file is actually there. Printing
out the java.library.path property seemingly reveals the correct path:
/home/mike/.java/deployment/ext

Two things come to mind:
1. Is the library executable?
2. Does it ignore the fact that .java is hidden?

HTH

Menno H.
 
N

Nigel Wade

Mike said:
Hi

I'm trying to load Java3D library files from an arbitrary location.

In windows i use this code that works fine:

String fileSeparator = System.getProperty("file.separator");
String home = System.getProperty("user.home");
String path = home + fileSeparator + "Application Data" + fileSeparator
+ "Sun" + fileSeparator + "Java" + fileSeparator + "Deployment" +
fileSeparator + "ext";
System.setProperty("java.library.path", path);
System.loadLibrary("j3dcore-d3d");
System.loadLibrary("j3dcore-ogl");

Now i want to do the same in linux using this code but fails:

String fileSeparator = System.getProperty("file.separator");
String home = System.getProperty("user.home");
String path = home + fileSeparator + ".java" + fileSeparator +
"deployment" + fileSeparator + "ext";
System.setProperty("java.library.path", path);
System.loadLibrary("j3dcore-ogl");

It spawns this errror:

java.lang.UnsatisfiedLinkError:no j3dcore-ogl in java.library.path

I've made sure the libj3dcore-ogl.so file is actually there. Printing
out the java.library.path property seemingly reveals the correct path:
/home/mike/.java/deployment/ext
I've tried using
System.load("/home/mike/.java/deployment/ext/libj3dcore-ogl.so") instead
using an absolute path to no avail.
Does anyone know why this doesn't work in linux?

Thanx
Mike

Can you actually change the library search path during execution? Certainly you
can change the system property java.library.path, but does it actually have any
effect? I thought you had to do this via the command line
option -Djava.library.path

You should be able to load the library either by setting the LD_LIBRARY_PATH
environment variable to the directory containing the library in question and
using System.loadLibrary() or directly by using System.load().

How does if fail when you use System.load()?

Things to check.

Are the permissions correct? i.e. can you actually read the file. This applies
to all directories on the path, not just the permissions on file in question.
You need execute permission on each directory and read on the file.

Is the file of the correct type for the architecture? ie. ensure you using a
32bit library on a 32bit system, or a 64bit library on a 64bit system.
 
N

Nigel Wade

Nigel said:
Is the file of the correct type for the architecture? ie. ensure you using a
32bit library on a 32bit system, or a 64bit library on a 64bit system.

Sorry, I meant to say:
a 32bit library with a 32bit JVM and a 64bit library with a 64bit JVM.
 
R

Roedy Green

System.setProperty("java.library.path", path);
System.loadLibrary("j3dcore-d3d");
System.loadLibrary("j3dcore-ogl");


System.load takes a fully qualified filename, e.g. C:\dlls\myjni.dll,
one ending in .dll (or .so for Linux or Solaris). System.loadLibrary
takes an unqualified filename, e.g. myjni and appends the .dll or .so
for you. The idea is you can write more platform-independent code this
way. I have had more success with System.load during debugging then
flipping to System.loadLibrary once all is working.


I would be very careful about modifying java.library.path.

First, it may be only informational.
Second, if you remove anything from the path you could stop other
classes from loading.

--
Roedy Green Canadian Mind Products
http://mindprod.com
"Humanity is conducting an unintended, uncontrolled, globally pervasive experiment
whose ultimate consequences could be second only to global nuclear war."
~ Environment Canada (The Canadian equivalent of the EPA on global warming)
 

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top