eclipse.ini 文件中的环境变量

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2426317/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 14:30:20  来源:igfitidea点击:

Environment variables in eclipse.ini file

eclipseparsingcommand-linevariables

提问by Andrei Pozolotin

Does eclipse.inior eclipse command line support variable parsing such as $PATHor ${java.home}?

eclipse.ini或 eclipse 命令行是否支持诸如$PATH或 之类的变量解析${java.home}

回答by VonC

As mentioned in FAQ: How do I run Eclipse?

常见问题解答中所述:如何运行 Eclipse?

If available under the eclipse/jre directory, the Eclipse JRE will be used; otherwise the launcher will consult the system path variable. Eclipse will NOT consult the JAVA_HOME environment variable.

如果在 eclipse/jre 目录下可用,则将使用 Eclipse JRE;否则启动器将查询系统路径变量。Eclipse 不会查询 JAVA_HOME 环境变量。

a eclipse command line can use environment variable (like any other command):

eclipse 命令行可以使用环境变量(像任何其他命令一样):

eclipse -vm $jAVA_HOME/bin

would work.

会工作。

But Eclipse itself (or eclipse.ini) will not use parse directly an environment variable.
A eclipse.ini like this oneonly use full paths.

但是 Eclipse 本身(或 eclipse.ini)不会直接使用 parse 环境变量。像这样
eclipse.ini只使用完整路径。



Actually, bug 102239is already asking for that kind of feature... since 2005!

实际上,bug 102239已经在要求这种功能了……自 2005 年以来!

Bug 102239 - [launcher] Environment variable substitution in <launcher>.ini/eclipse.ini

It'd be very helpful if the launcher would support the insertion of environment variables in the <launcher>.ini.
Whatever form might make sense (e.g. @ENV, %ENV%, ${ENV}, ${env_var:ENV})

e.g. something like

错误 102239 - [启动器] 中的环境变量替换 <launcher>.ini/eclipse.ini

如果启动器支持在<launcher>.ini.
任何形式都有意义(例如@ENV, %ENV%, ${ENV}, ${env_var:ENV}

例如像

-vm
${MYRCPAPP_VM}
-mx${MYRCPAPP_HEAPSIZE}

But the answers ask for help on this:

但答案在这方面寻求帮助:

The launcher is written in C. The code is in the platform-launcher project.

[To] want this on any argument including the vm, vmargs etc, in which case this would need to happen in the native code.

启动器是用 C 编写的。代码在平台启动器项目中。

[要] 在任何参数上都需要这个,包括 vm、vmargs 等,在这种情况下,这需要在本机代码中发生。

回答by Paolo

Elaborating the @VonC answer I have created a simple file eclipse.batcontaining the following simple line:

详细说明@VonC 答案我创建了一个eclipse.bat包含以下简单行的简单文件:

start eclipse.exe -vm %WORK_DIRECTORY%\tools\Java\jdk1.8.0_73\bin\javaw.exe

Where I have used a system variable. Now, instead of calling directly eclipse.exe, I call eclipse.batand this does the trick.

我在哪里使用了系统变量。现在,eclipse.exe我不是直接调用,而是调用eclipse.bat,这可以解决问题。

回答by Bartek T

In my case I wanted to have redefined user name (used e.g. in @author tag) so I have changed the shortcut to eclipse to point to the following:

就我而言,我想重新定义用户名(例如在@author 标签中使用),因此我已将 eclipse 的快捷方式更改为指向以下内容:

C:\Java\eclipse\eclipse.exe -vmargs -Duser.name=%eclipse_user%

Then I have defined user variable eclipse_user which can be set by each user separately. For my needs it's enough.

然后我定义了用户变量 eclipse_user 可以由每个用户单独设置。满足我的需求就够了。