tags:

views:

301

answers:

1

Hello,

I recently pickup Java so I have very limited knowledge, but I would like to know if it's possible to get DLL version using Java. If it is not possible, is it possible to use C# to get Jar version through the manifest file?

+1  A: 

It's certainly possible in each case - you just need to write code to read the appropriate file format.

I suspect it's vastly simpler to find the manifest in a jar file from C# than the assembly version from Java though - it's just a case of loading a zip file and finding the META-INF/MANIFEST.MF file. Reading the file is easy, as it's plain text.

Depending on exactly what you mean by the version of a DLL, you may need to do all manner of things - if you're talking about .NET assembly attributes, I don't know whether they're placed in some easily-fetchable place; my experience of parsing Portable Executable (PE) files is that it's slightly tricky unless you've got library support. Of course if you can find a Java library which knows the format already, it may become trivial...

Jon Skeet
I find worthy to mention that not all the JARs have the version number in its MANIFEST.MF
victor hugo
Very glad to hear that it can be done because I've searched on google but couldn't find anything. I can apply the same approach in C# like reading from a text file to read the manifest, but wouldn't I need to unzip the Jar file first before I can read manifest?
Bopha
But so far that Jar files that I have been working with, they all have manifest, so that case I won't worry.
Bopha
Thanks Jon Skeet, I think I will use C# instead to extract the Jar file version since you meantioned it's more simpler.
Bopha
You don't need to unzip them to the file system - use something like SharpZipLib to read through until you get the entry you want, then read the contents into memory.
Jon Skeet
Thanks for the tips, I will search more on SharpZipLib.
Bopha
Thank you for pointing me to this useful library. It works wonderful.
Bopha
Hi Jon, Is there a way to read Windows DLL's version using Java?
Chandan .
@ChanLFC: As I said in the answer, you'd have to find a library which understands the PE format... or write one yourself.
Jon Skeet