String javaHome = System.getenv("JAVA_HOME"); System.out.println("Java Home Directory: " + javaHome);
String path = System.getenv("PATH"); String[] pathEntries = path.split(";"); for (String entry : pathEntries) { System.out.println(entry); }This code retrieves the value of the `PATH` environment variable, splits it into individual entries, and then prints each entry to the console. The `System.getenv` method is part of the `java.lang` package, which is automatically imported into every Java program.