Well, i want yo know if so than how can you convert dll files into packages that can be used in java. Or is there any other way of using dll files by using classes.
I doubt you could convert as dll's contain precompiled native code. System.loadLibrary() works to load dll's, but I guess you would need to create a wrapper class if you want a class for it.
For example "jawin" : The Java/Win32 integration project (Jawin) is a free, open source architecture for interoperation between Java and components exposed through Microsoft's Component Object Model (COM) or through Win32 Dynamic Link Libraries (DLLs).
what you need to do is to use JNI. First, create a java files that have the native method(to call your c or C++ methods). Check out java keyword native. Please note(as suggested above) that you have to have
static{
system.loadLibrary("yourdll"
}
to call your dll. After your java class has been successfully built, run javah command on the file, i.e.
c:\javah myjava
this will create a c/c++ header file. then you have to provide the cpp or c file for this c/c++ project. Then using your c/c++ workspace, build the dll and put it in a common place like windows\system32 so java can find the dll and load it up.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.