I am currently working on a J2ME polish application, just enhancing it. I am finding difficulties to get the exact version of the jar file. Is there any way to find the version of the jar file for the imports done in the class? I mean if you have some thing, import x.y.z; can we know the version of the jar x.y package belongs to?
相关问题
- Dependencies while implementing Mocking in Junit4
- Android version code for App updating
- Modelica libraries use different MSL version
- Unable to generate jar file for Hadoop
- Using task scheduler for running java jar (from ba
相关文章
- How to get java main class from jar file
- java.lang.NoClassDefFoundError: javax/servlet/http
- Default arguments in JAR-manifest
- intellij build jar artifact containing gradle depe
- Use local jar as a dependency in my Gradle Java pr
- ant jar's mainclass
- PowerShell ISE: how to run new PowerShell version
- IntelliJ compile for Java 7 JRE using Java 8 SDK
This simple program will list all the cases for version of jar namely
Manifest file not found
It uses the javaxt-core jar which can be downloaded from http://www.javaxt.com/downloads/
Just to expand on the answers above, inside the META-INF/MANIFEST.MF file in the JAR, you will likely see a line:
Manifest-Version: 1.0
← This is NOT the jar versions number!You need to look for
Implementation-Version
which, if present, is a free-text string so entirely up to the JAR's author as to what you'll find in there. See also Oracle docs and Package Version specificaionEach jar version has a unique checksum. You can calculate the checksum for you jar (that had no version info) and compare it with the different versions of the jar. We can also search a jar using checksum.
Refer this Question to calculate checksum: What is the best way to calculate a checksum for a file that is on my machine?
Basically you should use the
java.lang.Package
class which use the classloader to give you informations about your classes.example:
I think logback is known to use this feature to trace the JAR name/version of each class in its produced stacktraces.
see also http://docs.oracle.com/javase/8/docs/technotes/guides/versioning/spec/versioning2.html#wp90779
It can be checked with a command
java -jar jarname
You need to unzip it and check its
META-INF/MANIFEST.MF
file, e.g.or more specific: