英文:
Mars Eclipse is sticking to a non-existing version of Java. How can I change it?
问题
因为与我正在进行的项目相关的原因,我需要使用Mars版本的Eclipse和Java 1.7。
我已经尝试了我所能想到的一切来设置Eclipse使用这个版本的Java,但是Eclipse总是指向另一个JDK。
我尝试过通过eclipse.ini文件覆盖配置。我尝试过删除我拥有的所有Java版本,然后只重新安装我想要的JDK。我还尝试过从终端打开Eclipse,同时尝试从那里覆盖设置。
截至目前,我已经删除了所有版本的Eclipse和Java的所有文件夹,以及相关的环境变量,然后重新开始(又一次)。我的JDK文件夹在C:,我的%JAVA_HOME%
指向C:/jdk1.7/bin,而eclipse.ini中有-vm¶C:\jdk1.7\bin
(我已经确保我使用了正确的换行符并且尝试过使用单划线和双划线分别在vm
之前,以及在JDK二进制文件夹路径中使用\
和/
)。但是当我尝试打开Eclipse时,它会崩溃,因为它在寻找C:\jre7\lib\amd64\jvm.cfg
(jre7并不存在)。当我点击该窗口的确定按钮后,我会得到另一个窗口,上面写着:
Java已启动,但返回退出码=1
C:\Windows\**system32**\javaw.exe
-jar
C:\Users\myuser\eclipse\plugins\org.eclipse.equinox.launcher_1.3.100.v2015
0511-1540.jar
-os win32
-ws win32
-arch x86_64
-showsplash
-launcher C:\Users\myuser\eclipse\eclipse.exe
-name Eclipse-mars
--launcher.library
C:\Users\myuser\eclipse\plugins\org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.300v20150602-1417\eclipse_1611.dll
-startup
C:\Users\myuser\eclipse\plugins\org.eclipse.equinox.launcher_1.3.100.v2015
0511-1540.jar
--launcher.overrideVmargs
-exitdata 13a0_f0
-vm C:\Windows\**system32**\javaw.exe
-vmargs
-jar
C:\Users\myuser\eclipse\plugins\org.eclipse.equinox.launcher_1.3.100.v2015
0511-1540.jar
请注意,它引用了system32,这是一个我从未安装或定位过Java的文件夹,也从未在任何Eclipse设置中由我设置过。
我已经花了一个星期的时间来尝试解决这个问题,我是我同事中唯一遇到这个问题的人。我的操作系统是Windows 10。
英文:
For reasons related to the project I'm working on, I need to use Mars Eclipse and Java 1.7.
I've tried everything I can think of to set Eclipse to use this version of Java, but Eclipse will just point to a different JDK.
I tried overwriting the configuration via eclipse.ini. I've tried deleting all versions of Java I had and reinstalling only the JDK I wanted. I tried opening Eclipse from a terminal, while also trying to overwrite the settings from there.
As of now, I deleted every folder from all versions of Eclipse and Java and the relevant environment variables, and started from scratch (again). I have my JDK folder in C:, my %JAVA_HOME%
is pointing towards C:/jdk1.7/bin and eclipse.ini has -vm¶C:\jdk1.7\bin
(I already made sure I was using the right newline character and tried with both, single and double dashes before vm
and \
and /
for the route to the JDK bin folder). And when I try to open Eclipse, it crashes, as it's looking for C:\jre7\lib\amd64\jvm.cfg
(jre7 doesn't exist). When I click OK to that window, I get another one saying
Java was started but returned exit code=1
C:\Windows\**system32**\javaw.exe
-jar
C:\Users\myuser\eclipse\plugins\org.eclipse.equinox.launcher_1.3.100.v2015
0511-1540.jar
-os win32
-ws win32
-arch x86_64
-showsplash
-launcher C:\Users\myuser\eclipse\eclipse.exe
-name Eclipse-mars
--launcher.library
C:\Users\myuser\eclipse\plugins\org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.300v20150602-1417\eclipse_1611.dll
-startup
C:\Users\myuser\eclipse\plugins\org.eclipse.equinox.launcher_1.3.100.v2015
0511-1540.jar
--launcher.overrideVmargs
-exitdata 13a0_f0
-vm C:\Windows\**system32**\javaw.exe
-vmargs
-jar
C:\Users\myuser\eclipse\plugins\org.eclipse.equinox.launcher_1.3.100.v2015
0511-1540.jar
Note it references system32, a folder in which Java has never been installed or located in, and which has never been set by me in any Eclipse setting.
I've got a week trying to figure out how to fix this and I am the only one among my coworkers who has this problem. My OS is Windows 10.
答案1
得分: 1
有关“Eclipse使用哪个JDK”的概念有两种完全不同的情况:
- Eclipse本身是用Java编写的应用程序。它在哪个JVM(
java.exe
)上运行? - 当您在Eclipse中开发Java代码时,Eclipse需要一个JVM来执行各种任务:例如,要知道
java.lang.String
存在,或者要运行或调试此项目。Eclipse可以配置使用多个您想要的Java安装,并且可以告诉任何给定的项目使用您在Eclipse中配置的任何VM。运行Eclipse的VM不必是用于运行/调试您在Eclipse中编写的Java项目,也不必作为这些项目的引导类路径的相同VM。
我很难理解为什么您必须在1.7 VM上运行_eclipse本身_。所以不要这样做;不要转到首选项,搜索“已安装的JRE”,然后添加1.7 JRE。然后右键单击项目,选择“构建路径”,您可以告诉Eclipse使用该JRE/JDK运行该项目并用作其引导类路径。
唯一真正需要在1.7上运行Eclipse的原因是,如果您被迫使用一些已过时的Eclipse插件,这些插件在1.8+上无法正常运行 - 这种情况不太可能发生。
在这种情况下,-vm参数不是用于指向可执行文件的内容。
适当的参数是类似C:\Program Files\Java\1.7.025
的内容 - 我不太确定Windows安装的目录结构如何工作,但它应该是您可以找到java.exe
的目录。而不是指向真正的Java的java.exe(即C:\Windows\System32中的java.exe对于此操作无用)。在此中不包括javaw.exe
。
英文:
There are two entirely different concepts of 'which JDK is eclipse using':
- Eclipse it itself an application written in java. Which JVM (
java.exe
) is it running on? - When you develop java code in eclipse, eclipse needs a JVM for various purposes: To know that
java.lang.String
exists, for example. Or to run or debug this project. Eclipse can be configured with as many java installations as you want, and any given project can be told to use any VM you told eclipse about. The VM that runs eclipse does not have to be the same VM that is used for running / debugging java projects you're writing in eclipse, nor to serve as bootclasspath for these projects.
I'm having a hard time fathoming why you would have to run eclipse itself on a 1.7 VM. So don't; go to preferences, search for 'installed JREs', and add the 1.7 JRE. Then right click on a project, build path
, and you can tell eclipse to use that JRE/JDK to run that project and to serve as bootclasspath for it.
The only real reason you'd have to run eclipse on 1.7 is if you are forced to use some outdated eclipse plugin that somehow doesn't run properly on 1.8+ - unlikely.
In that case, the -vm parameter is NOT the thing to use to point at the executable.
The proper argument is something like C:\Program Files\Java\1.7.025
- I'm not quite sure how the dir structure works out on windows installations, but it's supposed to be the directory within which you find 'java.exe', pretty much. And not the java.exe that points at the real java (i.e. the one in C:\Windows\System32 is not useful for this exercise). You also don't include the 'javaw.exe' in this.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论