How to run Eclipse with different Java version?
EclipseJavaEclipse Problem Overview
I am using Eclipse for developing BlackBerry Applications. I have JDK/JRE 7 currently on my computer, but that makes the BlackBerry plugins crash. Actually is a known issue and the only thing need to be done is run Eclipse with JDK/JRE 6 instead of 7.
I downloaded and installed version 6. However I am pretty sure Eclipse still uses 7. I had the same problem a year ago and I remembered I had to configure some System Variables and it worked, but I can't really find the solution now.
Any idea on this one? Important! I don't want to compile in version 6, which means I just have to choose the Java version through Eclipse. What I need is Eclipse to start
with version 6.
Eclipse Solutions
Solution 1 - Eclipse
-
Open eclipse config file
eclipse.ini
in your Eclipse folder. -
Add
-vm yourPath\Java\jre6\bin\javaw.exe
like:-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.v20120522-1813 -product org.eclipse.epp.package.java.product --launcher.defaultAction openFile --launcher.XXMaxPermSize 256M -vm C:\Java\jre6\bin\javaw.exe ...
If the path contains spaces there is no need to escape them, see the Eclipse Wiki for more specs. The -vm
option and the path must be on separate lines. The -vm
option must come before the -vmargs
option. On Linux, the path would typically be /bin/java
instead of the Windows path shown above. You must use the Java and Eclipse versions must match (i.e. 32-bit Eclipse runs on 32-bit Java and 64-bit Eclipse runs on 64-bit Java).
Solution 2 - Eclipse
Note that option -vm C:\Java\jre6\bin\javaw.exe
should be right before -vmargs
. Otherwise you'll get 'Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit'
Solution 3 - Eclipse
Do this:
-
Go to the folder where eclipse is installed (the one that has the eclipse.exe program in)
-
Open the text file eclipse.ini with notepad or something similar
-
Add the following lines to specify the JVM location using the -vm argument
-vm c:/jre/bin/javaw.exe
Now start eclipse in the usual way.
Make sure to position the -vm argument before -vmargs, since the latter is passed to the VM on startup it will be too late to set the VM after this.
More info is available on the Eclipse wiki
You could also have changed the system path as per one of the other answers but this would change the JVM being used for the whole system. If you use the eclipse.ini settings it allows everything else to use the latest JVM.
Solution 4 - Eclipse
Many hints given already. Anyway I will just provide the recommended way of doing it which might help for future reviews of that question:
- Use the eclispe.ini file (folder where the eclipse binary resides)
- Add the -vm option with the path of the jre to startup with
> i.e Windows
> -vm
> C:\Java\jdk1.6.0_45\jre\bin\javaw.exe
> i.e Linux
> -vm
> /opt/sun-jdk-1.6.0.02/bin/java
> - The -vm option must occur after the other Eclipse-specific options (such as -product, --launcher.*, etc), but before the -vmargs option, since everything after -vmargs is passed directly to the JVM.
- The -vm option and its value (the path) must be on separate lines.
- The value must be the full absolute or relative path to the Java executable, not just to the Java home directory.
Solution 5 - Eclipse
Since none of the answers worked for me this is my solution:
I downloaded java 6 and i installed it. Then in the program files , inside the folder of java , i copied the folder jre6. I pasted it inside the eclipse folder and renamed it jre.
Thats it! When inside the eclipse installation folder your have a folder named jre , then the java in there is the java that eclipse will run with.
Thank you all for your answers!
Solution 6 - Eclipse
These two options worked for me on Windows:
-
Edit eclipse.ini
-vm C:/Java/jdk1.7.0_71/jre/bin -vmargs ...
-
Copy jre folder to eclipse folder.
So after the copy I have C:\eclipse\jre folder which is a copy of C:\Java\jdk1.7.0_71\jre
Solution 7 - Eclipse
I modified eclipse.ini file as follows (added my local JDK path) and it fixed eclipse loading issue.
-vm
C:\Program Files\Java\jdk1.8.0_251\bin
Solution 8 - Eclipse
If you want to make sure you are running you java apps in Windows 7 with an specific java version:
1 - Check out what which version is running by default. Run cmd to go to the console and type: java -version
> C:>java -version > > java version "1.6.0_45" Java(TM) SE Runtime Environment (build > 1.6.0_45-b06) Java HotSpot(TM) Client VM (build 20.45-b01, mixed mode, sharing)
2 - Change the default jdk by changing the path. Example here. Make sure you java.exe from your desired jdk is before any other java.exe from any other JDK in the path. ex. in JDK 1.6 you java.exe should be here C:\java\jdk1.6\bin\java.exe.
Once you have changed the path, open a new console and verify again which jdk version you are running.
3 - Make sure in eclipse.ini param -vm another jre version is not set.
Solution 9 - Eclipse
I too faced same issue while running eclipse with different version then default on the system.
I created a symlink of required jre directory under eclipse directory and then it was all working.
For windows user: symlink is similar to creating shortcut
Hope it helps you too.