I have multiple version of jre's installed on my system. Is there any way i would know which JRE version is being used by the application during run time.
There might be possible that application may use lower version of JRE -"Not Sure"
Thanks in Advance.
You can put this into static code of a class so it runs only once: (This code is not mine. You can refer here:- Getting Java version at runtime
And if that does not turn up..
Other links you can refer:
http://www.oracle.com/technetwork/java/javase/versioning-naming-139433.html http://docs.oracle.com/javase/1.5.0/docs/relnotes/version-5.0.html
Like a_horse_with_no_name said: you can do this by calling
System.getProperty("java.version")
.If you need this information to make sure that the program is started using the correct JVM version, then try this:
All you have to do is change
MAJOR_VERSION
andMINOR_VERSION
to the values that you want and recompile. I use it in my programs all the time and it works well. Warning: it doesn't work if you changeSystem.getProperty("java.version")
withSystem.getProperty("java.runtime.version")
... the output is slightly different.Using
will return the version of the currently running JVM.
Sometimes this does not return anything (don't know why). In that case you can try: