I am going to demonstrate example which shows how to get environment variables from Java code
import java.io.IOException;import java.util.Map;public class Main{ public static void main(String[] args) throws IOException{ Map<String,String>variables = System.getenv(); for (String variablesName:variables.keySet()){ System.out.format("%s=%s%n",variablesName,variables.get(variablesName)); } System.out.println("\nOnly one varaible"); System.out.println("PATH = " + System.getenv("PATH")); }}As you can see this example get all and then get one specific variable.
Download this example.
No related posts.

Recent Comments