Home » Tip Bank » Java
  • Comment on this Article
Language: Java
Expertise: Intermediate
Mar 1, 2019
  • facebook
  • twitter
  • in
  • Email

WEBINAR:

On-Demand

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


Watch

Finding the Java Version Programatically

import java.util.*;

public class FindJavaVersion
{
   public static void main(String args[])
   {
      FindJavaVersion findJavaVersion = new FindJavaVersion();
      findJavaVersion.printDetails();
   }
   
   private void printDetails()
   {
      Properties systemProperties = System.getProperties();
      System.out.println("Java version: " + systemProperties.get("java.version"));
      System.out.println("File separator : " + systemProperties.get("file.separator"));
      System.out.println("Java home: " + systemProperties.get("java.home"));
      
   }
}

/*

Expected output:

[root@mypc]# java FindJavaVersion
Java version: 1.8.0_102
File separator : /
Java home: /opt/Java/jre1.8.0_102

*/
M S Sridhar
 
Submit a Tip
Browse "Java" Tips
Browse All Tips
activatejavascript.org
activatejavascript.org