Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I have a dll that I wan to load in jsp

 
Haval Kadhem
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic