This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes JNI  Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "JNI  " Watch "JNI  " New topic
Author

JNI

Frank Jacobsen
Ranch Hand

Joined: May 17, 2002
Posts: 348
Can anyone tel me why this dosent work, i have to classes:
Class 1:
public class Cmethods {

public native void AttachToServer();
}
Class 2:
public class RPCClient {
public static void main(String[] args) {
System.out.println("Indl�ser maskin kode");
try {
System.loadLibrary("MML32DLL.dll");
} catch (Error e) {
System.out.println("Fejl ved indl�sning af maskinkode: " + e);
System.exit(1);
}
System.out.println("Opretter objekt.");
Cmethods objekt = new Cmethods();
System.out.println("Kalder metode implementeret i maskinkode.");
objekt.AttachToServer();
System.out.println("lige efter kald til attach");
}
}
I call my program from the dos prompt:
java -Djava.libary.path=. -classpath . RPCClient
I get this exception:
java.lang.UnsatisfiedLinkError: no MML32DLL.dll in java.library.path
I don�t understand this exception, becouse my Dll is in the same path as my class files in the directory, where im running my application, and i got the libary.path ???
Help !!!
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Hi,
I believe the problem is that you're not supposed to include the ".dll" here -- i.e., use just


[Jess in Action][AskingGoodQuestions]
Frank Jacobsen
Ranch Hand

Joined: May 17, 2002
Posts: 348
YEHHHHHH, your the best !

In all the examples i saw at google and other places, the .ddl was in the code....
But it works without the .ddl
Thanks a lot !
Scott Ding
Greenhorn

Joined: Nov 27, 2002
Posts: 13
oh, I must remember it.
Mathews P Srampikal
Ranch Hand

Joined: Nov 26, 2002
Posts: 211
Hi,
Is it Possible to pass some arguments to that method like given below.
<B>public native void AttachToServer(String str);</B>
If then that C function also has to take the same String as a parameter.
Thanks.


Thanks,
Mathews
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JNI
 
Similar Threads
Exception
Call a method to set data to JTable?
Exception
SecurityException when running applet in IE5
try/catch/finally