• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
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: 22849
132
Eclipse IDE Spring 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: 22849
132
Eclipse IDE Spring 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: 22849
132
Eclipse IDE Spring 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.
reply
    Bookmark Topic Watch Topic
  • New Topic