Setting environment variables in eclipse that references other environment variables

假如想象 提交于 2020-01-14 05:15:14

问题


I have Eclipse Helios with a java program set up. I'm attempting to create two environment variables

ReportingManagerHome=C:\rp
ReportingManagerConfig=${ReportingManagerHome}\config

I then run my program with

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.

Now how do I work around this so that I can define cascading environment variables in Eclipse?


回答1:


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.

The most reliable way to do it is to go to Preferences>Run/Debug>String Substitution and define an eclipse variable there.

Then define the environment variables in your launch config:

ReportingManagerHome=${RMH}
ReportingManagerConfig=${RMH}\config



回答2:


In Eclipse Mars and later you can use

${env_var:VAR_NAME}


来源:https://stackoverflow.com/questions/6307975/setting-environment-variables-in-eclipse-that-references-other-environment-varia

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!