Antim Verma
Antim Verma

Reputation: 19

Java -Version? How does it gives installed java version details

we run java program in cmd using java , same way for finding installed java version we use Java -version in cmd, So how does it gives us version details? Is there any Version class defined in java API ?Its seems funny Question though

Upvotes: 1

Views: 123

Answers (2)

Akshay Chordiya
Akshay Chordiya

Reputation: 4841

Java stores the version into the java.exe. In case you want to try for yourself just open the java.exe into any text editor or hex editor and you will find version written inside it.

Upvotes: 0

Serg M Ten
Serg M Ten

Reputation: 5606

Use

System.getProperty("java.vendor")
System.getProperty("java.version")
System.getProperty("java.vm.vendor")
System.getProperty("java.vm.name")
System.getProperty("java.vm.version")
System.getProperty("os.name")
System.getProperty("os.version")
System.getProperty("os.arch")

And for getting the default character encoding

new java.io.OutputStreamWriter(new java.io.ByteArrayOutputStream()).getEncoding()

Upvotes: 5

Related Questions