This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Svelte and Sapper in Action and have Mark Volkmann on-line!
See this thread for details.
Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

JNI vs simply running an external program.

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good morning Ladies and gents.

I was just wondering if it's better if possible to run an external ".exe" program (maybe written in c) rather than using JNI.

I've had a look at JNI and it looks like it could be alot easier to simply just run an exe.

I need this for getting the hard drive serial number (Which I know can't be done in java).

Any advice or thoughts on this topic would be greatly appreciated.

thanks in advance.
 
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Running an external program is much slower than calling a JNI function. But, if you are only doing it once (probably true in your case), running an external program may be fast enough.

Passing complicated data between and external program and your Java code can be more difficult than doing it in JNI. However, in your case, the data is unlikely to be complicated.

Once you have added your first bit of JNI to your program, every subsequent bit of JNI is much easier than the first; you'll already have sorted out how to build the library, how to load it, how to deploy it in your installations etc. Therefore, think carefully. If getting the hard-drive serial number is the only thing you need to do outside pure Java, it's probably not worth JNI. If you are likely to end up needing lots of similar facilities, you should probably go for JNI.
 
Dylan Margoczi
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for the advice Peter.

I'll take the external program route as I highly doubt I'll need to do anything externally again.

thanks again.
 
Nothing? Or something? Like this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic