dcsimg
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Tip: Find Out the Java Version

See how to figure out what version of Java you are using.


advertisement

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


This is generally useful, specifically if you want to perform some operations based on the version of Java you are using.

public class JavaVersion
{
   public static void main(String args[])
   {
      JavaVersion javaVersion = new JavaVersion();
      javaVersion.proceed();
   }
   
   private void proceed()
   {
      //This works in Java 8 and prior
      //For Java 9, there is a new api available in Runtime class
      String javaVersion = System.getProperty("java.version");
        System.out.println("Java Version: " + javaVersion); 
   }
}

/*

Expected output:

[root@mypc]# java JavaVersion
Java Version: 1.8.0_221

*/

 

Visit the DevX Tip Bank

 





   
Sridhar M S. is a Java developer from Bangalore, India. He holds a master's degree in Computer Science.
Thanks for your registration, follow us on our social networks to keep up-to-date