How to check Java version?

M

Mickey Segal

A

Andrew Thompson

The simple answer used to be to check java.version or java.vm.version, but
the current JRE 1.6.0_05 reports both these values as 10.0-b19.  I filed a
bug on similar behavior in JRE 1.7 (soon to appear athttp://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6674346) but was
surprised to find that the problem extends back to JRE 1.6 as well.

How do the Java testers athttp://www.java.com/en/download/help/testvm.xml
andhttp://www.javatester.org/version.htmlget the right answer despite this
bug?

Huhh? The makers of the second version checker
actually link to a page that shows the source,
and there is nothing special about it.

I tried their applet and recompiling the code
from the stated source and got the same answer of
'Java Version: 1.6.0 from Sun Microsystems Inc.'
for both the live applet and compiled code.

The command line says..
1.6.0-b105 (amongst other stuff, but for some
reason I cannot 'drage/select' text in the CLI
window of this machine I'm using).

For *major* version (if that is what interests
you) I would suggest using the technique I used
in the JavaVersionApplet. try/catches on
instantiating classes introduced in each
subsequent version, incrementing a counter
to keep track.
 
M

Mickey Segal

Oops. Only java.vm.version is reporting wrong. java.version is reporting
correctly. In the past java.vm.version was useful for getting build
numbers.

I tried their applet and recompiling the code
from the stated source and got the same answer of
'Java Version: 1.6.0 from Sun Microsystems Inc.'
for both the live applet and compiled code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top