wood burning stoves 2.0*
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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
Author

I have a dll that I wan to load in jsp

Haval Kadhem
Greenhorn

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
Bartender

Joined: Aug 20, 2001
Posts: 1817

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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: I have a dll that I wan to load in jsp
 
Similar Threads
JSP loading a dll
How to resolve .dll already loaded in another classloader problem?
load a C++ library from a jsp...
Dll Loading
Will WAS help