• 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:

Get File Version

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How to use java to get file version?
windows exe file.
 
Sheriff
Posts: 22773
130
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are two possible ways, neither of them is portable since this kind of information is not available on all systems:
1) use JNI. GetFileVersionInfo or GetFileVersionInfoEx are probably the native API calls you need.
2) call some external program that returns this information using Runtime.exec or ProcessBuilder. I don't know any such program though.
 
Peng Ge
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote:There are two possible ways, neither of them is portable since this kind of information is not available on all systems:
1) use JNI. GetFileVersionInfo or GetFileVersionInfoEx are probably the native API calls you need.
2) call some external program that returns this information using Runtime.exec or ProcessBuilder. I don't know any such program though.


Yes, I tried JNA. But I get runtime ERRORs.
It is hard for me to mapping the data type.
Can you please help me?
 
Rob Spoor
Sheriff
Posts: 22773
130
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've never used JNA, so not really. But why can't you do this in JNI? That's like JNA but coded in C, C++ or another language that isn't Java.
 
Peng Ge
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote:I've never used JNA, so not really. But why can't you do this in JNI? That's like JNA but coded in C, C++ or another language that isn't Java.



Yes, But I dont know how to program in C. Seems JNI is much complicated than JNA. Can you help me with the code?
I just want to read file version.
 
Rob Spoor
Sheriff
Posts: 22773
130
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Like I said, I have no experience with JNA, so the answer to that is no. As for JNI, if you don't know C then I don't know if it's a wise idea to go that way. Perhaps someone else can help you with the JNA type mappings.
 
I'm full of tinier men! And a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic