提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
读取环境变量
public class Main { /**来自 N o w J a v a . c o m**/ public static void main(String[] args) { if (args.length > 0) { String value = System.getenv(args[0]); if (value != null) { System.out.println(args[0].toUpperCase() + " = " + value); } else { System.out.println("No such environment variable exists"); } } else { System.out.println("No arguments passed"); } } }