如何在 Eclipse 中设置 Java 路径,以便我可以在外部驱动器上运行它?

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

How do I set the Java path in Eclipse so I can run it on an external drive?

javaeclipseportable-applications

提问by PHLAK

I have Eclipse 3.5.1 and Java Portable (from Portableapps.com) installed on a portable hard drive and would like to point my Eclipse to use the portable apps Java version. This will allow me to use Eclipse on a computer even if Java isn't installed. How do I accomplish this?

我在便携式硬盘驱动器上安装了 Eclipse 3.5.1 和 Java Portable(来自 Portableapps.com),并希望让我的 Eclipse 使用便携式应用程序 Java 版本。即使未安装 Java,这也允许我在计算机上使用 Eclipse。我该如何实现?

采纳答案by Amro

Perhaps take a look at the Eclipse Portableproject on SourceForge

也许看看SourceForge 上的Eclipse Portable项目



EDIT: Alternatively, edit the eclipse.inifile and add:

编辑或者,编辑eclipse.ini文件并添加:

-vm 
..\path-to-jre\bin\javaw.exe

[The new line after -vm matters]

[-vm 后面的新行很重要]

回答by Jon Quarfoth

Open Eclipse.

打开日食。

Navigate to Window > Preferences > Java > Installed JREs

导航到“窗口”>“首选项”>“Java”>“已安装的 JRE”

Add the JRE on your portable hard drive

在您的便携式硬盘驱动器上添加 JRE

Set this as your default JRE.

将此设置为您的默认 JRE。

回答by Rappster

I know it's been ages since this post has been active, but I might have three additional details to contribute (at least they seemed to be crucial in my case):

我知道这篇文章已经活跃很久了,但我可能还有三个额外的细节要贡献(至少在我的情况下它们似乎是至关重要的):

  1. Just as stated here, paths need to be separated by /, not\in eclipse.ini
  2. At least on MS Windows 7 (64 bit), it seems to be very important that you put the -vm ../path-to-jre/bin/javaw.exeat the very beginningof the eclipse.inifile and that it is actually twolines:

    -vm

    ../path-to-jre/bin/javaw.exe

    Otherwise Eclipse seems to first try to find C:\Windows\System32\javaw.exewhich will cause an error (at least my error log says so)

  3. Seems that the following path (found here) also works: ../path-to-jre/bin/server/jvm.dll
  1. 正如此处所述,路径需要由/,而不是\in分隔eclipse.ini
  2. 至少在微软Windows 7(64位),这似乎是非常重要的,你把-vm ../path-to-jre/bin/javaw.exe在最开始的的eclipse.ini文件,它实际上是2线:

    -vm

    ../path-to-jre/bin/javaw.exe

    否则 Eclipse 似乎首先尝试查找C:\Windows\System32\javaw.exe哪个会导致错误(至少我的错误日志是这样说的)

  3. 似乎以下路径(在这里找到)也有效:../path-to-jre/bin/server/jvm.dll

As of 2013-04-19 for Eclipse 4.2.2 (Juno), this is how my eclipse.inilooks like:

截至 2013 年 4 月 19 日,对于 Eclipse 4.2.2 (Juno),这就是我的eclipse.ini样子:

-vm 
c:/jre/Java64/bin/javaw.exe
-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.200.v20120913-144807
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vmargs
-Xms40m
-Xmx512m

Note that /Java64/bin/javaw.exeis taken from portable java

请注意,/Java64/bin/javaw.exe取自便携式 java