[英]Setting the correct PATH for Eclipse
I recently changed my path so I could follow along in the Head First Java book and I had Eclipse before. 我最近改变了自己的路径,所以我可以在Head First Java书中继续学习,之前我有过Eclipse。 Now when I try to get onto Eclipse again it won't open because it says it can't find a JRE or JDK to use in my directory.
现在,当我再次尝试进入Eclipse时,它将无法打开,因为它说它无法在我的目录中找到要使用的JRE或JDK。 I have moved the JDK file around.
我已经移动了JDK文件。 I have jdk1.8.0_60 downloaded.
我已经下载了jdk1.8.0_60。 So how can I get Eclipse to open again?
那么我怎样才能让Eclipse再次打开?
Like Abob said : 像阿布说 :
Eclipse doesn't consult the
JAVA_HOME
variableEclipse不参考
JAVA_HOME
变量
You should specify where Eclipse should find your JDK in the file eclipse.ini
. 您应该在
eclipse.ini
文件中指定Eclipse应该在哪里找到您的JDK。 Specifically, the following parameter (note that it is 2 separate lines in the ini file): 具体来说,以下参数(注意它在ini文件中是2个单独的行):
-vm
C:\Java\JDK\1.8\bin\javaw.exe
or wherever your javaw.exe happens to be. 或者你的javaw.exe恰好在哪里。
Note: The format of the ini
file is very particular; 注意:
ini
文件的格式非常特殊; make sure to consult https://wiki.eclipse.org/Eclipse.ini to ensure you get it exactly right. 请务必查阅https://wiki.eclipse.org/Eclipse.ini以确保您完全正确。
Eclipse folder has an initialization file which is used by eclipse on launch/Double click it is named as eclipse.ini. Eclipse文件夹有一个初始化文件,eclipse在启动时使用/双击它命名为eclipse.ini。 Add the following lines in eclipse.ini file.
在eclipse.ini文件中添加以下行。 Where the vm defines the path of J VM with which we want eclipse to use.
vm定义了我们希望eclipse使用的J VM的路径。
-vm
C:\Program Files\Java\jdk1.8\bin\javaw.exe
Make sure you have add the above lines separately and above the following line 确保您已单独添加以上行并在以下行上方添加
--launcher.appendVmargs
-vmargs
Go to System Properties > Advanced > Enviroment Variables
and look under System variables
转到
System Properties > Advanced > Enviroment Variables
然后查看System variables
JAVA_HOME
variable JAVA_HOME
变量 Even though Eclipse doesn't consult the JAVA_HOME
variable, it's still a good idea to set it. 尽管Eclipse没有参考
JAVA_HOME
变量,但设置它仍然是个好主意。 See How do I run Eclipse? 请参阅如何运行Eclipse? for more information.
欲获得更多信息。
If you have not created and/or do not see JAVA_HOME
under the list of System variables
, do the following: 如果您尚未在
System variables
列表下创建和/或未看到JAVA_HOME
,请执行以下操作:
New...
at the very bottom New...
Variable name
, type JAVA_HOME
exactly Variable name
,请完全键入JAVA_HOME
Variable value
, this could be different depending on what bits your computer and java are. Variable value
,这可能会有所不同,具体取决于您的计算机和Java的位数。
C:\\Program Files\\Java\\jdk1.8.0_60
C:\\Program Files\\Java\\jdk1.8.0_60
C:\\Program Files\\Java\\jdk1.8.0_60
C:\\Program Files\\Java\\jdk1.8.0_60
C:\\Program Files (x86)\\Java\\jdk1.8.0_60
C:\\Program Files (x86)\\Java\\jdk1.8.0_60
If you have created and/or do see JAVA_HOME
, do the following: 如果您已创建和/或确实看到
JAVA_HOME
,请执行以下操作:
System variables
that you see JAVA_HOME
in JAVA_HOME
中看到的System variables
下的行 Edit...
at the very bottom Edit...
Variable value
, change it to what was stated in #3 above based on java's and your computer's bits. Variable value
,根据java和计算机的位将其更改为上面#3中所述的值。 To repeat: C:\\Program Files\\Java\\jdk1.8.0_60
C:\\Program Files\\Java\\jdk1.8.0_60
C:\\Program Files\\Java\\jdk1.8.0_60
C:\\Program Files\\Java\\jdk1.8.0_60
C:\\Program Files (x86)\\Java\\jdk1.8.0_60
C:\\Program Files (x86)\\Java\\jdk1.8.0_60
PATH
variable PATH
变量 System variables
with PATH
in it System variables
下的行,其中包含PATH
Edit...
at the very bottom Edit...
New
New
C:\\Program Files (x86)\\Java\\jdk1.8.0_60
OR C:\\Program Files\\Java\\jdk1.8.0_60
depending on the bits of your computer and java (see above ^). C:\\Program Files (x86)\\Java\\jdk1.8.0_60
或 C:\\Program Files\\Java\\jdk1.8.0_60
具体取决于计算机和java的位(参见上文^)。 Enter
and Click New
again. Enter
并再次单击“ New
。 C:\\Program Files (x86)\\Java\\jdk1.8.0_60\\jre
OR C:\\Program Files\\Java\\jdk1.8.0_60\\jre
depending on the bits of your computer and java (see above again ^). C:\\Program Files (x86)\\Java\\jdk1.8.0_60\\jre
OR C:\\Program Files\\Java\\jdk1.8.0_60\\jre
具体取决于计算机和java的位(请参见上文^)。 Enter
and press OK
on all of the related windows Enter
并在所有相关窗口上按OK
Variable value
textbox (or something similar) drag the cursor all the way to the very end Variable value
文本框(或类似的东西)中,将光标一直拖到最后 ;
) if there isn't one already ;
则添加分号( ;
) C:\\Program Files (x86)\\Java\\jdk1.8.0_60
OR C:\\Program Files\\Java\\jdk1.8.0_60
C:\\Program Files (x86)\\Java\\jdk1.8.0_60
或 C:\\Program Files\\Java\\jdk1.8.0_60
;
) ;
) C:\\Program Files (x86)\\Java\\jdk1.8.0_60\\jre
OR C:\\Program Files\\Java\\jdk1.8.0_60\\jre
C:\\Program Files (x86)\\Java\\jdk1.8.0_60\\jre
OR C:\\Program Files\\Java\\jdk1.8.0_60\\jre
eclipse.ini
eclipse.ini
eclipse.ini
file and copy-paste it in the same directory (should be named eclipse(1).ini
) eclipse.ini
文件并将其复制粘贴到同一目录中(应该命名为eclipse(1).ini
) eclipse.ini
to eclipse.ini.old
just in case something goes wrong eclipse.ini
重命名为eclipse.ini.old
以防万一出错 eclipse(1).ini
to eclipse.ini
eclipse(1).ini
重命名为eclipse.ini
Open your newly-renamed eclipse.ini
and replace all of it with this: 打开新重命名的
eclipse.ini
并将其全部替换为:
-startup plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar --launcher.library plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.100.v20110502 -product org.eclipse.epp.package.java.product --launcher.defaultAction openFile --launcher.XXMaxPermSize 256M -showsplash org.eclipse.platform --launcher.XXMaxPermSize 256m --launcher.defaultAction openFile -vm C:\\Program Files\\Java\\jdk1.8.0_60\\bin\\javaw.exe -vmargs -Dosgi.requiredJavaVersion=1.5 -Xms40m -Xmx1024m
XXMaxPermSize
may be deprecated, so it might not work. XXMaxPermSize
可能已被弃用,因此可能无效。 If eclipse still does not launch, do the following: 如果eclipse仍未启动,请执行以下操作:
eclipse.ini
eclipse.ini
eclipse.ini.old
to eclipse.ini
eclipse.ini.old
重命名为eclipse.ini
eclipse -vm C:\\Program Files (x86)\\Java\\jdk1.8.0_60\\bin\\javaw.exe
eclipse -vm C:\\Program Files (x86)\\Java\\jdk1.8.0_60\\bin\\javaw.exe
键入eclipse -vm C:\\Program Files (x86)\\Java\\jdk1.8.0_60\\bin\\javaw.exe
Try updating your eclipse and java to the latest version. 尝试将您的eclipse和java更新到最新版本。 8u60 (
1.8.0_60
) is not the latest version of java. 8u60(
1.8.0_60
)不是java的最新版本。 Sometimes, the latest version of java doesn't work with older versions of eclipse and vice versa. 有时,最新版本的java不适用于旧版本的eclipse,反之亦然。 Otherwise, leave a comment if you're still having problems.
否则,如果您仍然遇到问题,请发表评论。 You could also try a fresh reinstallation of Java.
您也可以尝试重新安装Java。
I am using Windows 8.1 environment. 我正在使用Windows 8.1环境。 I had the same problem while running my first java program after installing Eclipse recently.
我最近在安装Eclipse后运行第一个java程序时遇到了同样的问题。 I had installed java on d drive at d:\\java.
我在d:\\ java上的d驱动器上安装了java。 But Eclipse was looking at the default installation c:\\programfiles\\java.
但Eclipse正在查看默认安装c:\\ programfiles \\ java。 I did the following:
我做了以下事情:
Modified my eclipse.ini file and added the following after open: 修改了我的eclipse.ini文件并在打开后添加了以下内容:
-vm d:\\java\\jdk1.8.0_161\\bin
While creating the java program I have to unselect default build path and then select d:\\java. 在创建java程序时,我必须取消选择默认构建路径,然后选择d:\\ java。
After this, the program ran well and got the hello world to work. 在此之后,该程序运行良好,让hello world工作。
There are working combinations of OS, JDK and Eclipse bitness. OS,JDK和Eclipse bitness有工作组合。 In my case, I was using a 64-bit JDK with a 32-bit Eclipse on a 64-bit OS.
就我而言,我在64位操作系统上使用64位JDK和32位Eclipse。 After downgrading the JDK to 32-bit, Eclipse started working.
在将JDK降级到32位后,Eclipse开始工作。
Kindly use one of the following combinations. 请使用以下组合之一。
32-bit OS, 32-bit JDK, 32-bit Eclipse (32-bit only) 32位操作系统,32位JDK,32位Eclipse(仅限32位)
64-bit OS, 32-bit JDK, 32-bit Eclipse 64位操作系统,32位JDK,32位Eclipse
64-bit OS, 64-bit JDK, 64-bit Eclipse (64-bit only) 64位操作系统,64位JDK,64位Eclipse(仅限64位)
For me none worked. 对我来说没有人工作。 I compared my existing
eclipse.ini
with a new one and started removing options and testing if eclipse worked. 我将现有的
eclipse.ini
与新的eclipse.ini
进行了比较,并开始删除选项并测试eclipse是否有效。
The only option that prevented eclipse from starting was -XX:+UseParallelGC
, so I removed it and voilá! 阻止eclipse启动的唯一选择是
-XX:+UseParallelGC
,所以我删除了它并且瞧!
I have resolved this problem by adding or changing variables in environment variables. 我通过在环境变量中添加或更改变量来解决此问题。 Go to Win7 -> My Computer - > Properties - > Advanced system settings -> environment Variables
转到Win7 - >我的电脑 - >属性 - >高级系统设置 - >环境变量
Good Luck 祝好运
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.