Reputation: 19
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
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
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