1

I have a couple of .dll files and I have to call methods of those .dll files from Java. How can I do this ? Is there any alternative way to do this ?

Eddard Stark
  • 3,575
  • 8
  • 35
  • 51
  • 1
    JNA may be the simplest. – Peter Lawrey Nov 02 '12 at 09:03
  • 1
    Check this: http://stackoverflow.com/questions/9485896/calling-c-dll-from-java – Azodious Nov 02 '12 at 09:04
  • @PeterLawrey I did not know of JNA. Looks simpler than JNI, but how standard/extended is it? – SJuan76 Nov 02 '12 at 09:08
  • JNI is builtin whereas JNA is an additional library which might not be available on every platform. If you have Windows, Linux or Solaris you should expect JAN to work quite well. JNA slightly slower than JNI but its ease of use can more than make up for this. – Peter Lawrey Nov 02 '12 at 09:09

2 Answers2

1

You can use Java Native InterFace (JNI). You will probably need to either modify/add the methods with the appropiate signature to your DLL, or write a C/C++ wrapper for it.

SJuan76
  • 24,532
  • 6
  • 47
  • 87
1

Standard way to call native function is to use JNI, but you can also take a look at Java Native Access (JNA). With help of JNA you can call native functions from a dll without writing boilerplate code.

Ivan Mushketyk
  • 8,107
  • 7
  • 50
  • 67