This is generally useful, specifically if you want to perform some operations based on Java version and so on.
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
*/
Related Articles
- Automation of Tasks
- Terminating the Current Java Runtime Programmatically
- Converting Base 10 numbers to Binary numbers
Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.






















