Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Get File Version

 
Peng Ge
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to use java to get file version?
windows exe file.
 
Rob Spoor
Sheriff
Pie
Posts: 20380
45
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
Pie
Posts: 20380
45
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
Pie
Posts: 20380
45
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Peng Ge
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Spoor wrote:And really, read your PMs and follow the instructions in them. That's not optional.

I tried to change the name. But It was denied. I will try that again.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic