Sponsored Content
Top Forums UNIX for Advanced & Expert Users Unix Machine for calling Native Method of C Post 302095523 by sbeyonduf007 on Wednesday 8th of November 2006 01:33:36 AM
Old 11-08-2006
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..
 

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
File::Spec::Native(3pm) 				User Contributed Perl Documentation				   File::Spec::Native(3pm)

NAME
File::Spec::Native - Use native OS implementation of File::Spec from a subclass VERSION
version 1.003 SYNOPSIS
# This serves little purpose on its own but can be useful in some situations # For example: use Path::Class 0.24; # convert foreign file type into native type # without having to know what the current OS is foreign_file(Win32 => $win32_path)->as_foreign("Native"); # or to build a file-spec dynamically (possibly taking the type from input): my $type = get_requested_file_spec(); # can return "Native" foreign_file($type => $file_path); # having $type be "Native" is an alternative to having to do: my $file = $type ? foreign_file($type, $file_path) : file($file_path); DESCRIPTION
This module is a stupid hack to make the default File::Spec behavior available from a subclass. This can be useful when using another module that expects a subclass of File::Spec but you want to use the current, native OS format (automatically detected by File::Spec). For example: "as_foreign" in Path::Class (as of version 0.24) allows you to translate a Path::Class object from one OS format to another. However, there is no way to specify that you want to translate the path into the current, native OS format without guessing at what that format is (which may include peeking into @File::Spec::ISA). This module @ISA File::Spec. SEE ALSO
o File::Spec o Path::Class o <https://rt.cpan.org/Ticket/Display.html?id=49721> SUPPORT
Perldoc You can find documentation for this module with the perldoc command. perldoc File::Spec::Native Websites The following websites have more information about this module, and may be of help to you. As always, in addition to those websites please use your favorite search engine to discover more resources. o Search CPAN The default CPAN search engine, useful to view POD in HTML format. http://search.cpan.org/dist/File-Spec-Native <http://search.cpan.org/dist/File-Spec-Native> o RT: CPAN's Bug Tracker The RT ( Request Tracker ) website is the default bug/issue tracking system for CPAN. http://rt.cpan.org/NoAuth/Bugs.html?Dist=File-Spec-Native <http://rt.cpan.org/NoAuth/Bugs.html?Dist=File-Spec-Native> o CPAN Ratings The CPAN Ratings is a website that allows community ratings and reviews of Perl modules. http://cpanratings.perl.org/d/File-Spec-Native <http://cpanratings.perl.org/d/File-Spec-Native> o CPAN Testers The CPAN Testers is a network of smokers who run automated tests on uploaded CPAN distributions. http://www.cpantesters.org/distro/F/File-Spec-Native <http://www.cpantesters.org/distro/F/File-Spec-Native> o CPAN Testers Matrix The CPAN Testers Matrix is a website that provides a visual overview of the test results for a distribution on various Perls/platforms. http://matrix.cpantesters.org/?dist=File-Spec-Native <http://matrix.cpantesters.org/?dist=File-Spec-Native> o CPAN Testers Dependencies The CPAN Testers Dependencies is a website that shows a chart of the test results of all dependencies for a distribution. <http://deps.cpantesters.org/?module=File::Spec::Native> Bugs / Feature Requests Please report any bugs or feature requests by email to "bug-file-spec-native at rt.cpan.org", or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=File-Spec-Native <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=File-Spec-Native>. You will be automatically notified of any progress on the request by the system. Source Code http://github.com/rwstauner/File-Spec-Native <http://github.com/rwstauner/File-Spec-Native> git clone http://github.com/rwstauner/File-Spec-Native AUTHOR
Randy Stauner <rwstauner@cpan.org> COPYRIGHT AND LICENSE
This software is copyright (c) 2011 by Randy Stauner. 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.14.2 2011-07-14 File::Spec::Native(3pm)
All times are GMT -4. The time now is 10:59 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy