• 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
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

JNI vs simply running an external program.

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Something must be done about this. Let's start by reading this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic