Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsC/C++ Programs From Java using JNI
https://www.eclipse.org/forums/index.php/mv/msg/187872/596036/#msg_596036
Iam using Eclipse 3.2 in Linux. I try to create a programe in Java using
Eclipse, which one execute a function in C/C++. For that I am try to use
JNI methord in JAVA. When i try this, I get one error message,
"
Exception in thread "main" java.lang.UnsatisfiedLinkError: no TestHello in
java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
at java.lang.Runtime.loadLibrary0(Runtime.java:822)
at java.lang.System.loadLibrary(System.java:993)
at TestHello.<clinit>(TestHello.java:8)
"
Please help me to solve the error.
I create a Java project named TestHello and a class (default) named
TestHello, and the contents of the .java file is
==================================================
class TestHello
{
public native void sayHello();
static
{
try
{
System.loadLibrary("TestHello");
}
catch(Exception e)
{
System.out.println("exc");
}
}
public static void main(String[] args)
{
TestHello h = new TestHello();
h.sayHello ();
}
}
========================================================
and save the file. After that I convert this java project into a C
project through, right click on the project -> new -> others -> C ->
convert to a C/C++ Make Project. Then the Perspetive view into C/C++.
create a file named " TestHello.c " and the contents of the file is, and
save the file.
After that, take the properties, and take the C/C++ Make Project. Uncheck
the Use Default option and give the command like " make -f Makefile " .
Check on the option , " Build on Resource save (Auto Build )" and give
the " Make Build Target " variable as " all ". And set " Apply " and " OK
".
After this you get a header file "TestHello.h" a .so file " TestHello.so "
and create a Binaries.
When i run this programe using : Run ->Run.... -> JavaApplication
then an errer message display like this "
Exception in thread "main" java.lang.UnsatisfiedLinkError: no TestHello in
java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
at java.lang.Runtime.loadLibrary0(Runtime.java:822)
at java.lang.System.loadLibrary(System.java:993)
at TestHello.<clinit>(TestHello.java:8)
"
Please help me for solving this problum.
Sabeesh C.S]]>Sabeesh C.S.2007-03-26T10:45:46-00:00Re: C/C++ Programs From Java using JNI
https://www.eclipse.org/forums/index.php/mv/msg/187872/698137/#msg_698137
Cmlo 2011-07-18T21:17:48-00:00