Link to home
Start Free TrialLog in
Avatar of Steve Sperber
Steve SperberFlag for United States of America

asked on

java.lang.UnsatisfiedLinkError: (A file or directory in the path name does not exist)

Tried a few examples on AIX box and everytime I get the error as below:-

Calling C code from Java using JNI

java HelloWorld
The java class could not be loaded. java.lang.UnsatisfiedLinkError: ctest (Not found in java.library.path)

Open in new window


The "libctest.so" is very much in the path and LD_LIBRARY_PATH.

On running below  command.
export LD_LIBRARY_PATH=.
I get.
>  java HelloWorld
The java class could not be loaded. java.lang.UnsatisfiedLinkError: ctest (A file or directory in the path name does not exist.)

Open in new window



Below tutorial gives similar issue
Calling C From Java Is Easy

I am not sure what is going wrong
Avatar of Steve Sperber
Steve Sperber
Flag of United States of America image

ASKER

The error is "A file or directory in the path name does not exist".

I am putting the *.so in the path and LD_LIBRARY_PATH.
Is there anything else that i need to put on the path for this java file to run?
SOLUTION
Avatar of John Pope
John Pope
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I tried that out but still get the same error

training-> export CLASSPATH=.:/usr/java5_64/jre/bin:/usr/java5_64/bin:/usr/java5_64/include

training-> print $CLASSPATH
.:/usr/java5_64/jre/bin:/usr/java5_64/bin:/usr/java5_64/include

training-> java HelloWorld
The java class could not be loaded. java.lang.UnsatisfiedLinkError: ctest (A file or directory in the path name does not exist.)

training-> ls
HelloWorld.class  HelloWorld.java   libctest.so
HelloWorld.h      ctest.c

Open in new window

Sorry.  Are you saying that you have got $CLASSPATH set?

Also,  are you sure that there is no typo in the path?

Cheers, JP.
Ok,

You could try;

# ldd libctest.so

Open in new window


to evaluate library dependencies.

Also try;

# truss java HelloWorld

Open in new window


And see whether you have any 'load' system calls that look like they have failed in the output.

Cheers, JP.
I checked there is no typo. Also I cross verify the commands, what they do.

The ldd(library dependencies) show
training-> ldd libctest.so
libctest.so needs:
         /usr/lib/libc.a(shr.o)
         /unix
         /usr/lib/libcrypt.a(shr.o)

Open in new window



However on running truss I do see "Err#25 ENOTTY" not sure what it means.

Still it is not clear to me "what directory or path does not exist and where".
error-from-Truss-command.txt
The truss output doesn't show any obvious gotchas.  I think the errnotty is not a problem here.

Is the 'HelloWorld' code your own?  Perhaps there is something in your code that is making an incorrect system call to your ctest library.

Cheers, JP.
The Example that I tried is:-

Calling C code from Java using JNI - URL :-
http://stuf.ro/calling-c-code-from-java-using-jni

Code is attached.


//Command to execute is:-
java -Djava.library.path=.:/usr/java5_64/jre/bin:/usr/java5_64/bin:/usr/java5_64/include HelloWorld

//Output is :-
The java class could not be loaded. java.lang.UnsatisfiedLinkError: ctest (A file or directory in the path name does not exist.)

// the Java Version that was used
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build pap64devifx-20110627 (SR12 FP5 ))
IBM J9 VM (build 2.3, J2RE 1.5.0 IBM J9 2.3 AIX ppc64-64 j9vmap6423ifx-20110624 (JIT enabled)
J9VM - 20110623_85457_BHdSMr
JIT  - 20100623_16197ifx10_r8
GC   - FP22011_06)
JCL  - 20110627

Open in new window


I verified path "/usr/java5_64/include" contains jni.h.
However what makes me think is, "if there is some other command for Java 5 ?"
HelloWorld.h
ctest.c
HelloWorld.java
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Glad you got it figured out in the end.

Cheers, JP.
i want to resend as my solution is the only solution and not others.
Not knowing about -maix64 option in command like took a lot of my time