File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes importing native methods Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "importing native methods" Watch "importing native methods" New topic
Author

importing native methods

IB Diginit
Greenhorn

Joined: Feb 07, 2003
Posts: 3
I'm not sure if this is the right forum (newbie here), but I have been having a problem importing native methods into my java apps. The natives get called OK as long as all the files are in the same directory, but when I package the class and then try to import it into another app from another directory, I get the dreaded UnsatisfiedLinkError. <code follows>
//////////////////////////////////
package com.ibdiginit.utils;
public class ClearScreen{
public ClearScreen(){
clr();
}//constructor
private native void clr();
static{
System.loadLibrary("clr");
}
}//end class
////////////////////////////////////////
import com.ibdiginit.utils.*;
public class test{
public static void main(String[] args){
new ClearScreen();
}//end main
}
Any ideas??
Thanks in advance
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1863
hi,
r u on Unix?
if yes then u shd have LD_LIBRARY_PATH set up properly to have the lib<<name>>.so module at the right place..
usually in jre/bin
if u r on windows then also u can put it in PATH variable (the parent directory where the DLL resides) or in the jre/bin of ur java installation...
in java u can know where the JVM goes searching for these DLLs (or .so files) by printing System.getProperty("java.library.path") variable...

hope this helps....
thanks
maulin.


1. Have fun @ http://faq.javaranch.com/java/JavaRaq
2. Looking for simple infix2postfix conversion and postfix evaluation package? Click here
IB Diginit
Greenhorn

Joined: Feb 07, 2003
Posts: 3
Maulin, Thanks for the tip. Works great.
 
 
subject: importing native methods
 
Threads others viewed
call method from other class
Importing Classes in default package
packages
Packages And Import Statement
package
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture