Why is java -version implemented in Java?
Thomas Stüfe
thomas.stuefe at gmail.com
Sun Nov 22 06:35:22 UTC 2020
Hi Alan and David,
thanks for the additional information. I think now that the fact that
-version initializes the VM and runs a little java program is a fact that
is misused all over the place to do sanity checks.
Pity that the release file does not seem to be standardized. As for adding
a new option which is faster, as David mentioned, that already exists in
the (not well known) -XinternalVersion.
Thanks, Thomas
On Sat, Nov 21, 2020 at 9:20 AM Alan Bateman <Alan.Bateman at oracle.com>
wrote:
> On 20/11/2020 19:44, Thomas Stüfe wrote:
>
> :
>
> I know about the "release" file, but this does not seem like an obvious
> solution. I see this file mentioned as a way to quickly get the java
> release info, but it seems so strange and non-obvious. I feel bad that
> users have to even do that.
>
>
> The release file was added (I think JDK 7) to allow humans and scripts
> easily identify the run-time image. Running `java -version` is not an
> option in many cases, esp. when there is a possibility that the image is
> for a different platform or architecture. I remember there were issues some
> scripts (and one IDE in particular) that was peeking into jvm.dll to get
> vendor information. More recently, the release file was extended via JEP
> 220 so that scripts could easily identify the modules used to build that
> image. So I think it is very useful, even if it's not exactly what you want
> here.
>
> -Alan
>
More information about the jdk-dev
mailing list