Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JNI in solaris (urgent)

 
mou haj
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can any body help me...
i know how to call c functions from java code using JNI... we create a dll of the C program... but what should i do for Solaris
? please help
 
Dragon Liu
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi mou haj:
Maybe I can help you .
you can build a dll file on windows.
so the step on Solaris is very similar!
Step 1:
On Solaris, the following command builds a shared library example: libhello.so:
cc -G -I/usr/local/java/include -I/usr/local/java/include/solaris \
HelloWorldImp.c -o libhello.so
Step two:
After you do that,you can invoke the native method in java.
If you see an exception like the following, then you don't have your library path set up correctly.
java.lang.UnsatisfiedLinkError: no hello in shared library path
at java.lang.Runtime.loadLibrary(Runtime.java)
at java.lang.System.loadLibrary(System.java)
at
at java.lang.Thread.init(Thread.java)
use the following to set your library path.
% setenv LD_LIBRARY_PATH mylibrarypath
where mylibrarypath is the name of the directory that contains libhello.so.

 
mou haj
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx a l-o-t dragon lui
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic