• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

using JNI without knowing c/c++

 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi dear all,

i am learning JNI and i am quite confused in using the external dll in java.

i saw some tutorial require me to generate the .h file which seen like inreasonable because i don't know anything related to c++ or c. i just want to use the function in dll file.


is it possible for me to use dll file without having the knowledge in c++ and c? or at least i want to call some win32 api which is in dll form.
 
jamil lusa
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
some tutorial even require me to write the implementation in c/c++ language.

any guide is appreciated.
 
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To create a DLL you need to write some code and that would be the C/C++ code and then compile this to create a dll. I had long back written a small blog post on this, may be it will be helpful. So you need to know C and may not be in depth, but again that depends on what your function would do.
 
Marshal
Posts: 28237
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To use JNI, you have to have (on Windows, anyway) a DLL which is written in a specific way. You will have read about that in the tutorials you studied. Unfortunately the DLLs for the Windows APIs were not written in that way. That means that if you want to access them via JNI, then you have to write a wrapper DLL which is written in the JNI-specific way. This DLL would do nothing but delegate its calls to the underlying Windows API DLL.

Of course if you don't know C or C++ then even this small task is impossible. In that case you might want to look into Java Native Access.
 
reply
    Bookmark Topic Watch Topic
  • New Topic