get java environment variables in windows code example
Example 1: java get environment variables
public class Env {
public static void main (String[] args) {
for (String env: args) {
String value = System.getenv(env);
if (value != null) {
System.out.format("%s=%s%n",
env, value);
} else {
System.out.format("%s is"
+ " not assigned.%n", env);
}
}
}
}
Example 2: set java home path
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
# Add JAVA bin directory to the PATH variable
export PATH=$PATH:$JAVA_HOME/bin