Why is java -version implemented in Java?
Alan.Bateman at oracle.com
Fri Nov 20 18:08:07 UTC 2020
On 20/11/2020 16:22, Thomas Stüfe wrote:
> java -version seems to be called by scripts very frequently to get the java
> version. Folks complain about the time that takes.
> I always wondered, why is this implemented in java? Which requires the
> whole jvm machinery to start up just to print the version information.
> VersionProps.java seems not to be very complex; that information could have
> been baked into the launcher, or the hotspot.
> Or is using 'java -version' as a simple VM test just too convenient?
The alternative to scripts running `java -version` is to examine the
`release` file in the top-level directory. Could the scripts that you've
encountered be changed to look at that instead?
More information about the jdk-dev