eclipse 在eclipse中设置引用其他环境变量的环境变量
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6307975/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Setting environment variables in eclipse that references other environment variables
提问by fidesachates
I have Eclipse Helios with a java program set up. I'm attempting to create two environment variables
我有一个带有 Java 程序的 Eclipse Helios。我正在尝试创建两个环境变量
ReportingManagerHome=C:\rp
ReportingManagerConfig=${ReportingManagerHome}\config
ReportingManagerHome=C:\rp
ReportingManagerConfig=${ReportingManagerHome}\config
I then run my program with
然后我运行我的程序
System.out.println(System.getenv("ReportingManagerConfig"));
System.out.println(System.getenv("ReportingManagerConfig"));
Eclipse doesn't even call the java compiler. It throws up a pop up window with the error that environment variable ReportingManagerHome is not defined. I understand that since the java compiler has yet to be called, technically Eclipse is correct.
Eclipse 甚至不调用 java 编译器。它会弹出一个弹出窗口,提示未定义环境变量 ReportingManagerHome 的错误。我知道由于尚未调用 java 编译器,因此从技术上讲 Eclipse 是正确的。
Now how do I work around this so that I can define cascading environment variables in Eclipse?
现在我该如何解决这个问题,以便我可以在 Eclipse 中定义级联环境变量?
回答by Paul Webster
It won't recursively expand environment variables from the launch config.
它不会从启动配置递归扩展环境变量。
Even using ${env:VAR}
takes it from the environment variables from your eclipse process, not from your current launch config.
即使 using${env:VAR}
也从 eclipse 进程的环境变量中获取它,而不是从当前的启动配置中获取。
The most reliable way to do it is to go to Preferences>Run/Debug>String Substitutionand define an eclipse variable there.
最可靠的方法是转到Preferences>Run/Debug>String Substitution并在那里定义一个 eclipse 变量。
Then define the environment variables in your launch config:
然后在启动配置中定义环境变量:
ReportingManagerHome=${RMH}
ReportingManagerConfig=${RMH}\config
回答by NoodleOfDeath
In Eclipse Mars and later you can use
在 Eclipse Mars 及更高版本中,您可以使用
${env_var:VAR_NAME}