Let's say a banking application was developed in Java EE. And we are the new people working on that application now, not sure about the version of the Java EE used to develop that application.
How can we identify the version of Core Java/Java EE in which that project was developed?
How can we identify the version of Core Java/Java EE in which that project was developed?
(Note that "developed for" and "runs on" are different questions. I am answering the former ... which is what was asked.)
There is no 100% reliable way to do it.
If the project is built using Maven or Gradle, the project's declared dependencies (in the build files) will list specific versions of the Java EE APIs, and (typically) specific Java source and target version.
There probably be similar clues in an Ant build file, though in the case of dependencies you will be relying on clues in the pathnames of classpath entries ... which may not be there.
For Java EE, there may be clues in the namespace URLs used the XML files; e.g. web.xml
, application.xml
.
If the previous don't help, then you could test compile the codebase with various JDKs and against various Java EE APIs. That should narrow down the range of versions that the codebase is compatible with.
If you have existing .class
files, then javap
can tell you the target bytecode version that was used when building; see this answer. However, this is not a reliable indicator, because it doesn't tell you what version of Java the codebase was developed for.
If you want to find out which version or versions of Java a project is actually compatible with or actually runs on, the only way to find out for sure is to test it.
If you want to know which version of Java was used to compile the class, you can use javap
, available in the JRE and JDK. It reads your class bytecode and tells you the version.
javap -v out/com/kineolyan/tzio/diffs/Main.class
gives you:
Classfile /mnt/Grishka/Projets/project-tz-io/out/com/kineolyan/tzio/diffs/Main.class
Last modified 9 oct. 2018; size 1806 bytes
MD5 checksum 26b264396d74f1a68032bf5cd17aab09
final class com.kineolyan.tzio.diffs.Main
minor version: 0
major version: 53
flags: (0x0030) ACC_FINAL, ACC_SUPER
....
See this page to match major and minor versions to standard names. For example, 53.0 is Java9.
the code look like this
<properties>
<java.version>11</java.version>
<start-class>org.la.ecom.portal.teacher.EcommercePortalTeacherApplication</start-class>
</properties>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With