Results 1 to 10 of 10
  1. #1
    FlyNn is offline Senior Member
    Join Date
    Feb 2010
    Posts
    128
    Rep Power
    0

    Default Need a bit of clarification on JNI

    Hi Java users,

    I have a scanner device which does not have a Java driver. However, it has a .NET API and a .h file. Ive used the .NET API for writing a Windows service, which works.
    I would like to use the device on MACs, so I thought of writing java application.
    I've heard of the JNI. Am I thinking right that with JNI I could call methods from the .h file. Or is there a way for me to somehow to make this work?

    Thanks
    Measuring programming progress by lines of code is like measuring aircraft building progress by weight.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Need a bit of clarification on JNI

    JNI will not work nicely with .NET compiled libraries, but there are utilities out there on the net that can help you (whose names escape me at the moment).

  3. #3
    FlyNn is offline Senior Member
    Join Date
    Feb 2010
    Posts
    128
    Rep Power
    0

    Default Re: Need a bit of clarification on JNI

    I also have the .dll which is Windows API. is there a way I could utilise that? Through JNI or JNA?
    Measuring programming progress by lines of code is like measuring aircraft building progress by weight.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Need a bit of clarification on JNI

    Quote Originally Posted by FlyNn View Post
    I also have the .dll which is Windows API. is there a way I could utilise that? Through JNI or JNA?
    Yes, both JNI and JNA could very well use the .dll as long as it is not a .NET .dll (Microsoft gave the link libraries the same name even though their structures are very different -- shame on you Microsoft!!).

  5. #5
    FlyNn is offline Senior Member
    Join Date
    Feb 2010
    Posts
    128
    Rep Power
    0

    Default Re: Need a bit of clarification on JNI

    I can't seem to find a JNI API download. I am still a bit confused as to how the JNI works. All information I've been reading explains that I need to write implementations in java and build a .h using javah. Seems very convoluted. :S
    Measuring programming progress by lines of code is like measuring aircraft building progress by weight.

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Need a bit of clarification on JNI

    Quote Originally Posted by FlyNn View Post
    I can't seem to find a JNI API download.
    JNI is part of core Java, and so no download is needed. JNA on the other hand will require that you download some jar files and then place them in your project's classpath.


    I am still a bit confused as to how the JNI works. All information I've been reading explains that I need to write implementations in java and build a .h using javah. Seems very convoluted. :S
    If you're very familiar with C, then it's pretty straight-forward. I'm not, so I try to use JNA which I find much simpler to use.

  7. #7
    FlyNn is offline Senior Member
    Join Date
    Feb 2010
    Posts
    128
    Rep Power
    0

    Default Re: Need a bit of clarification on JNI

    I have downloaded the JNA API, but for some reason my IntelliJ can't seem to understand it after I add it as a library :S
    Measuring programming progress by lines of code is like measuring aircraft building progress by weight.

  8. #8
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Need a bit of clarification on JNI

    Quote Originally Posted by FlyNn View Post
    I have downloaded the JNA API, but for some reason my IntelliJ can't seem to understand it after I add it as a library :S
    Since that's an IntelliJ issue (and I use Eclipse), I'm sorry, but I can't help you there.

  9. #9
    FlyNn is offline Senior Member
    Join Date
    Feb 2010
    Posts
    128
    Rep Power
    0

    Default Re: Need a bit of clarification on JNI

    Thanks, for your help, Fubarable. I've downloaded the API again and it solved the issue. Now just need to find examples of how to make it work :)

    Thanks again
    Measuring programming progress by lines of code is like measuring aircraft building progress by weight.

  10. #10
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Need a bit of clarification on JNI

    Quote Originally Posted by FlyNn View Post
    Thanks, for your help, Fubarable. I've downloaded the API again and it solved the issue. Now just need to find examples of how to make it work :)

    Thanks again
    You're welcome and best of luck! I've done a little dabbling with JNA myself, but mostly for code that interacts directly with the Windows operating system user32.dll.

Similar Threads

  1. Help Clarification of code
    By deemu in forum New To Java
    Replies: 1
    Last Post: 02-06-2012, 02:53 PM
  2. Clarification of FileOutputStream
    By rogi85 in forum New To Java
    Replies: 4
    Last Post: 08-03-2011, 01:02 PM
  3. Struts Clarification
    By vinothkumarrvk in forum Web Frameworks
    Replies: 0
    Last Post: 02-26-2010, 03:24 PM
  4. need clarification in this statement.
    By Unsub in forum New To Java
    Replies: 5
    Last Post: 02-26-2010, 02:16 PM
  5. HELP! need clarification
    By ptsofathrty in forum New To Java
    Replies: 1
    Last Post: 12-16-2008, 09:02 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •