The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
calling a unix script in one box from another box trichyselva Shell Programming and Scripting 1 03-23-2007 02:09 PM
calling unix script from JSP??? Bhups Shell Programming and Scripting 1 06-07-2006 11:32 AM
calling script in target machine bryan UNIX for Dummies Questions & Answers 1 05-10-2006 03:41 PM
missing Path(in UNIX) when i launch a job on to unix machine using windows SSh megastar UNIX for Advanced & Expert Users 1 11-04-2005 07:36 AM
calling UNIX script from C/C++ omran High Level Programming 3 08-23-2002 07:21 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 11-08-2006
sbeyonduf007 sbeyonduf007 is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 4
Unix Machine for calling Native Method of C

hi all
i have a unix machine (FBD). I have Also installed java of Version (j2sdk1.4.1_07) on unix machine. Now i

want to Call C Native function in Java Which is declared as Native. i am doing this by following steps:
1) Making Echo.java File Which is having The following lines of code.
class Echo {
public native void runEcho();

static {
System.loadLibrary("echo");
}

public static void main(String[] args) {
new Echo().runEcho();
}
}
2) Compiling the Code:
$ javac Echo,java
$ javah Echo ----- which will make the header file used in c programe
3) writing the EchoImp.c File Which contains the following line of code
#include "jni.h"
#include "Echo.h"//the java class above compiled with javah
#include <stdio.h>

JNIEXPORT void JNICALL
Java_Echo_runEcho(JNIEnv *env, jobject obj)
{
char buf[64];
gets(buf);
printf(buf);
}
4) Making the Library echo
$ cc -G -I/usr/local/java/include -I/usr/local/java/include/linux
Echo.c -o libecho.so
5) Now Setting The Libarary Path
$ setenv LD_LIBRARY_PATH <Path>
6) Now Finally Excute the Java Program to call c function
$ java Echo


but while executing i m getting Error Like :
Exception in thread "main" java.lang.UnsatisfiedLinkError: no echo in java.libra
ry.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1403)
at java.lang.Runtime.loadLibrary0(Runtime.java:788)
at java.lang.System.loadLibrary(System.java:832)
at Echo.<clinit>(Echo.java:5)

i have also set the path but no results ....
plz help me out

Kamal Kant
email removed
sb

Last edited by vino; 11-08-2006 at 03:33 AM..
 

Bookmarks

Tags
linux

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:59 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0