Two Laptop Bag
The moose likes Other JSE/JEE APIs and the fly likes I have a dll that I wan to load in jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "I have a dll that I wan to load in jsp " Watch "I have a dll that I wan to load in jsp " New topic

I have a dll that I wan to load in jsp

Haval Kadhem

Joined: Aug 12, 2003
Posts: 1
how do you load a dll from a jsp, I have loaded it into a class that is being used by the jsp, but that does not work?
Joel McNary

Joined: Aug 20, 2001
Posts: 1824

If the dll is one that you wrote and contains native java methods, then all you need do is call System.loadLibrary("MyDllName"). And, yes, it is better to have your native funtions in a separate class, NOT the .jsp.
However, if the .dll is some oher (non-Java) .dll, what you need to do is write a java class with native methods that "wrap" the methods of the .dll that you want to call. So, if the .dll that you want has an "authorize" method, you would need to
1). write a java class with a native authorize method,
2). compile the java code,
3). use javah to come up with a .h file for your class,
4). write the corresponding C code that loads the target dll and calls the authorize method,
5). and (finally) compile the C code into a dll.
Then in your program, you call System.loadLibrary("MyDllName"), ad then call the "authorize" method in the java class that you wrote.
If it sounds complicated, it is. JNI is not an easy topic. You can find an on-line tutorial here

Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
I agree. Here's the link:
subject: I have a dll that I wan to load in jsp
It's not a secret anymore!