Sponsored Content
Top Forums UNIX for Advanced & Expert Users Unix Machine for calling Native Method of C Post 302095524 by sbeyonduf007 on Wednesday 8th of November 2006 01:36:01 AM
Old 11-08-2006
Executing Java code for calling Native Method of C Unix Machine

Executing Java code for calling Native Method of C Unix Machine



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..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

calling script in target machine

I know that schedulers handle callign scripts on different machines. If I want to call a script that's on the target machine and know whether the script ran fine or not, can it be done in shell script? what kind of commands would that have? Thank you (1 Reply)
Discussion started by: bryan
1 Replies

2. Programming

Issue related to native method

Hi, I am working with java and C/C++.In my java code I am using the native method to work with C/C++.So I am getting some error in C/C++ source code which I am not able to find it because It is throwing the only java null Exception.... Is there any way by which I can see the error in java console... (0 Replies)
Discussion started by: smartgupta
0 Replies

3. Programming

Regarding Native method

Hi, I am working with solaris 9 and I am using jre1.6. In my application,I am using java and C++ in my application.Basically we are using the java for front end and C/C++ for back hand.So I have to call the C/C++ source code form java code.we are using native methods for it.. So application... (1 Reply)
Discussion started by: smartgupta
1 Replies

4. Shell Programming and Scripting

calling a method inside awk

Hi All, How do we call a method existing in another file inside awk. After matching a pattern i want to call a method secureCopy that exists in another file, but method not getting called: ls -l | awk -v var2=$servername -v var1=$srcserverpath -v var3=$tgtpath '... (1 Reply)
Discussion started by: abhinav192
1 Replies

5. Shell Programming and Scripting

Calling Java Method from UNIX using shell script

Hi All, I need to call a java method from a shell script. I know we can use the command java ClassName to call the main method in it. But I need to call another method that is there in the class and pass an email to it. Can I use java ClassName.MethodName(email) Any help will be... (4 Replies)
Discussion started by: RahulK
4 Replies

6. UNIX for Advanced & Expert Users

best method to compare 2 big files in unix

Hi , I have a requirement to compare 2 files which can contain 40 million or more records and more than 20 fields to compare . Currently I am using awk scripting , and since awk has a memory issue, I am not able to process file more than 10 million records. Any suggestions or pointers to... (7 Replies)
Discussion started by: rashmisb
7 Replies

7. Shell Programming and Scripting

How to transfer files from unix machine to local machine using shell script?

Hi All.. Am new to Unix!! Am creating a shell script in which a scenario is like i have transfer the output file from unix machine (Server) to local directory (Windows xp). And also i have to transfer the input file from the local directory to Unix machine (Server) Any help from you... (1 Reply)
Discussion started by: vidhyaS
1 Replies

8. UNIX for Dummies Questions & Answers

Unix Shell Scripting( Calling from Unix to PLSQL)

Hello Experts, I have the following questions to be discussed here at this esteemed discussion forum. I have two Excel sheets which contain Unix Commands llike creating directory the structure/ftp/Copy/Zip etc to basically create an environment. I need help in understanding some of... (1 Reply)
Discussion started by: faizsaadq
1 Replies

9. Cybersecurity

Looking for suggestion on authentication method for UNIX/Windows

Hello, We have mid level infrastructure of all on-premises servers. All windows servers are getting authenticated by Microsoft Active Directory Services, half Unix (Solaris+Linux) servers are getting authentication by NIS and other half by LDAP. We have plans to migrate from NIS to LDAP, so... (2 Replies)
Discussion started by: solaris_1977
2 Replies

10. UNIX for Beginners Questions & Answers

Wanna learn native GUI programming in UNIX - Linux ?

Hi , wanna learn native GUI programming in Unix-Linux instead of Gtk and Qt. No problem. You don't need a cross platform Gui toolkit like Gtk and Qt. And the code and syntax is also not more or less than others. Check out this code for a simple mainwindow for your application that is openend in... (0 Replies)
Discussion started by: Sennenmut
0 Replies
Moose::Meta::Attribute::Native::Trait::Code(3)		User Contributed Perl Documentation	    Moose::Meta::Attribute::Native::Trait::Code(3)

NAME
Moose::Meta::Attribute::Native::Trait::Code - Helper trait for CodeRef attributes VERSION
version 2.0604 SYNOPSIS
package Foo; use Moose; has 'callback' => ( traits => ['Code'], is => 'ro', isa => 'CodeRef', default => sub { sub { print "called" } }, handles => { call => 'execute', }, ); my $foo = Foo->new; $foo->call; # prints "called" DESCRIPTION
This trait provides native delegation methods for code references. DEFAULT TYPE
If you don't provide an "isa" value for your attribute, it will default to "CodeRef". PROVIDED METHODS
o execute(@args) Calls the coderef with the given args. o execute_method(@args) Calls the coderef with the the instance as invocant and given args. BUGS
See "BUGS" in Moose for details on reporting bugs. AUTHOR
Moose is maintained by the Moose Cabal, along with the help of many contributors. See "CABAL" in Moose and "CONTRIBUTORS" in Moose for details. COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.16.2 2012-09-19 Moose::Meta::Attribute::Native::Trait::Code(3)
All times are GMT -4. The time now is 08:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy