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
jgdvishnuSoftware ArchitectAsked:
Who is Participating?
 
jgdvishnuSoftware ArchitectAuthor Commented:
it was not any of the path issue listed. it was adding -maix64 in command line of "gc" so that the so file is made for the 64 bit machine and not 32 bit.
The command was -

gcc -o libctest.so   -shared -maix64 -I/usr/java5/include com.insight.CTest.c -lc

Open in new window

0
 
jgdvishnuSoftware ArchitectAuthor Commented:
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?
0
 
John PopeIT ConsultantCommented:
Hi

Have you set up your java CLASSPATH environment variable?

If not, check that and try again.

# print $CLASSPATH

Open in new window


Should give you the path to the JDK/Java libs.

Cheers, JP.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
jgdvishnuSoftware ArchitectAuthor Commented:
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

0
 
John PopeIT ConsultantCommented:
Sorry.  Are you saying that you have got $CLASSPATH set?

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

Cheers, JP.
0
 
John PopeIT ConsultantCommented:
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.
0
 
jgdvishnuSoftware ArchitectAuthor Commented:
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
0
 
John PopeIT ConsultantCommented:
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.
0
 
jgdvishnuSoftware ArchitectAuthor Commented:
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
0
 
John PopeIT ConsultantCommented:
Hello

I'm sorry to say that it's getting a little out of my knowledge now.

Perhaps you could try explicitly defining the path to the libctest.so using the

-Djava.library.path

Open in new window


so assuming your working dir is /tmp/java/myspace

java -Djava.library.path=/tmp/java/myspace HelloWorld

Open in new window


(This also assumes that the libctest.so is in this library path)

See how you go.

Cheers, JP.
0
 
John PopeIT ConsultantCommented:
Glad you got it figured out in the end.

Cheers, JP.
0
 
jgdvishnuSoftware ArchitectAuthor Commented:
i want to resend as my solution is the only solution and not others.
0
 
jgdvishnuSoftware ArchitectAuthor Commented:
Not knowing about -maix64 option in command like took a lot of my time
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.