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


Tip of the Day
Language: Java
Expertise: Intermediate
Mar 1, 2019

WEBINAR:

On-Demand

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


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
 
Thanks for your registration, follow us on our social networks to keep up-to-date