How do I set the Java path in Eclipse so I can run

2019-04-02 06:02发布

问题:

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?

回答1:

Perhaps take a look at the Eclipse Portable project on SourceForge


EDIT: Alternatively, edit the eclipse.ini file and add:

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

[The new line after -vm matters]



回答2:

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.exe at the very beginning of the eclipse.ini file and that it is actually two lines:

    -vm

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

    Otherwise Eclipse seems to first try to find C:\Windows\System32\javaw.exe which 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

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

-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.exe is taken from portable java



回答3:

Open Eclipse.

Navigate to Window > Preferences > Java > Installed JREs

Add the JRE on your portable hard drive

Set this as your default JRE.