How to access JAVA_HOME programmatically

Create the following java file:

public class Environment { 

	public static void main(String[] argv){

		String javaHome = System.getenv("JAVA_HOME");
		
		System.out.println( "JAVA_HOME = " + javaHome ); 
	}
}

The output will be:

JAVA_HOME = v:/java/java_x64

References:

Java 7 System

Share this article:

Recent Comments