File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other JSE/JEE APIs and the fly likes Get File Version Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Get File Version" Watch "Get File Version" New topic
Author

Get File Version

Peng Ge
Greenhorn

Joined: May 20, 2011
Posts: 4
How to use java to get file version?
windows exe file.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19685
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Peng Ge
Greenhorn

Joined: May 20, 2011
Posts: 4
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

Joined: Oct 27, 2005
Posts: 19685
    
  20

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

Joined: May 20, 2011
Posts: 4
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

Joined: Oct 27, 2005
Posts: 19685
    
  20

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

Joined: May 20, 2011
Posts: 4
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
 
subject: Get File Version