SupportWriter space ↗
← Back to the journal
Core API

How do I get Java Home directory?

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

DWayan · 13 May 2008 · 1 min read

Article by Wayan · Source: Kode Java ↗

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

Comments 0

Share your questions, experiences, or feedback about this article.

No comments yet. Be the first to share your feedback.

← Explore more notes