问题
I have a computer and a Laptop. Because I code on both I put my eclipse workspace on a USB. But my computer has Java 7 and 6, but my laptop only has Java 6. I want to use Java 7 on my laptop too. Is there a way to put it on the USB and point to it to use. I have done research and found something about adding a JAR to a library, but when I download the Java 7 JDK it is in a whole bunch of folders. Am I doing it wrong or is that talking about something completely different.
As some people have mentioned. Its not my laptop entirely. Its my dads that he had from work. However he doesn't let install anything on it. Including java 7. Which does annoy me, but is why I'm asking this question.
回答1:
Install java into the eclipse directory (use folder jre/jdk instead of jre7), eclipse will pick it up (or it did for me on windows).
Alternatively edit eclipse.ini (there is a -VM parameter to specify where java resides).
also look at http://portableapps.com/node/929 or http://www.codeproject.com/Articles/417140/Eclipse-on-a-USB-flashdrive
Since there is some doubt about this method. I am using Windows Eclipse version (1.4.1.2), the jre7 directory was copied to jre under eclipse. There where no changes to eclipse.ini.
Unfortunately Java is installed on the machine I am using, but if I look in Eclipse configuration (Help >> About >> Configuration tab), Eclipse say's it is using the jre on the F drive (USB). If I rename the jre, it reverts to the java on the machine.
-vm
F:\eclipse\jre\bin\client\jvm.dll
eclipse.home.location=file:/F:/eclipse/
eclipse.launcher=F:\eclipse\eclipse.exe
eclipse.launcher.name=Eclipse
eclipse.p2.data.area=@config.dir/../p2/
eclipse.p2.profile=epp.package.java
eclipse.product=org.eclipse.epp.package.java.product
eclipse.startTime=1365550480114
eclipse.vm=F:\eclipse\jre\bin\client\jvm.dll
eclipse.vmargs=-Dosgi.requiredJavaVersion=1.5
......
sun.boot.class.path=F:\eclipse\jre\lib\resources.jar;F:\eclipse\jre\lib\rt.jar;F:\eclipse\jre\lib\sunrsasign.jar;F:\eclipse\jre\lib\jsse.jar;F:\eclipse\jre\lib\jce.jar;F:\eclipse\jre\lib\charsets.jar;F:\eclipse\jre\classes
sun.boot.library.path=F:\eclipse\jre\bin
......
java.endorsed.dirs=F:\eclipse\jre\lib\endorsed
java.ext.dirs=F:\eclipse\jre\lib\ext;C:\Windows\Sun\Java\lib\ext
java.home=F:\eclipse\jre
java.io.tmpdir=C:\Users\mum\AppData\Local\Temp\
java.library.path=F:\eclipse;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;F:/eclipse/jre/bin/client;F:/eclipse/jre/bin;F:/eclipse/jre/lib/i386;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\Dell\DW WLAN Card;C:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;C:\Program Files (x86)\Common Files\Roxio Shared\OEM\DLLShared\;C:\Program Files (x86)\Common Files\Roxio Shared\OEM\DLLShared\;C:\Program Files (x86)\Common Files\Roxio Shared\OEM\12.0\DLLShared\;C:\Program Files (x86)\Roxio\OEM\AudioCore\;C:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\WIDCOMM\Bluetooth Software\syswow64;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files\Bruce\jEdit;C:\Program Files (x86)\QuickTime\QTSystem\;c:\Regina;C:\Program Files\TortoiseSVN\bin;;F:\eclipse;;.
After renaming jre directory I get
-vm
C:\Program Files (x86)\Java\jre7\bin\client\jvm.dll
eclipse.home.location=file:/F:/eclipse/
eclipse.launcher=F:\eclipse\eclipse.exe
eclipse.launcher.name=Eclipse
eclipse.p2.data.area=@config.dir/../p2/
eclipse.p2.profile=epp.package.java
eclipse.product=org.eclipse.epp.package.java.product
eclipse.startTime=1365550310914
eclipse.vm=C:\Program Files (x86)\Java\jre7\bin\client\jvm.dll
eclipse.vmargs=-Dosgi.requiredJavaVersion=1.5
回答2:
I would just install Java 7 on your desktop laptop, but here is a step-by-step on installing and using Java on your stick:
http://www.dreamincode.net/forums/topic/42544-putting-java-on-your-flash-drive/
来源:https://stackoverflow.com/questions/15913515/is-there-a-way-to-install-java-7-onto-a-usb-and-use-that-for-projects-in-eclipse