从 windows 批处理文件中使用已配置的 JVM 启动 eclipse

Starting eclipse with configured JVM from windows batch file

我在使用 windows 批处理文件中正确配置的 JVM 启动 eclipse 时遇到问题。 我喜欢这样做,因为我有不同的工作区,不同的eclipse版本,不同的java版本和不同的配置。

我想问题出在我传递参数的方式上。我尝试了几种设置 '"' 的组合,但 none 奏效了。下面只是一个例子。

无论如何,有人可以帮忙吗? 谢谢:-)

后补: 抱歉,我忘了 - 问题是 JVM 的参数被忽略了

@echo off
ver
echo.

set thePathToJDK=C:\Program Files\AdoptOpenJDK\jdk-11.0.10x9-hotspot

rem to be checked - is JAVA_HOME needed by anyone ?
rem eclipse states that is neglecting JAVA_HOME
set JAVA_HOME=%thePathToJDK%

rem set path to vm ( shall be in harmony with path to JDK )
set thePathToJVM=%thePathToJDK%\bin\javaw

set thePathToEclipse=C:\eclipse\ ...

set thePathToEclipseWorkSpace=C:\ ...

rem set minimal path (for ECLIPSE/JAVA)
set theNewPath=%SystemRoot%\system32
set theNewPath=%theNewPath%;%SystemRoot%
set theNewPath=%theNewPath%;%SystemRoot%\System32\Wbem
set theNewPath=%theNewPath%;%SystemRoot%\System32\WindowsPowerShell\v1.0\
set path=%thePathToJDK%\bin;%theNewPath%
echo.
echo path used for ECLIPSE
echo %path%

set theCommand=%thePathToEclipse%\eclipse.exe   -data "%thePathToEclipseWorkSpace%"   -vm "%thePathToJVM%"   -vmargs -ea -Xmx4096m -Xss256m
echo.
echo %theCommand%

rem start eclipse with preconfigured Java
cmd /c %theCommand%

pause

在 Windows 上,当您使用 -vm 文件而不是文件夹时,您需要包含 VM 文件名的 .exe 部分。

正如@greg-449 所指出的,“参数”仅更改 Eclipse 本身使用的 Java。 我想做的事无法按我希望的方式完成 :-(