To get Java Home directory we can obtain it from system properties using the java.home
key.
package org.kodejava.lang;
public class JavaHomeDirectory {
public static void main(String[] args) {
String javaHome = System.getProperty("java.home");
System.out.println("JAVA HOME = " + javaHome);
}
}
On my computer this code give me the following output:
JAVA HOME = C:\Program Files\Java\jdk-17
Latest posts by Wayan (see all)
- How do I get number of each day for a certain month in Java? - September 8, 2024
- How do I get operating system process information using ProcessHandle? - July 22, 2024
- How do I sum a BigDecimal property of a list of objects using Java Stream API? - July 22, 2024