61

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.

Nathan
  • 8,093
  • 8
  • 50
  • 76
Johny Jaz
  • 875
  • 2
  • 13
  • 26

9 Answers9

89
  • 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).

Nathan
  • 8,093
  • 8
  • 50
  • 76
Van Dan NGUYEN
  • 991
  • 5
  • 5
  • 15
    The -vm option and its value (the path) must be on separate lines. See http://wiki.eclipse.org/Eclipse.ini for more specs. – user2793390 Aug 13 '14 at 20:23
  • 4
    Note that in Linux, the path would typically end in `/bin/java` (rather than `\bin\javaw.exe` as on win). – Amos M. Carpenter Jun 29 '15 at 05:14
  • Must make sure to link to the 64 or 32 bit java version depending which version eclipse you downloaded (for 64 bit it would be C:\Program Files\Java\jdk1.X.X\bin\javaw.exe) replace xx with version. – Harry Mar 14 '17 at 22:01
  • Worked for me only with a new line after the `-vm`. – eDeviser Apr 19 '21 at 14:32
  • Including this option (with a new line in between like you did) causes my JVM not to be able to start. It shows a fatal error, then a long screen with a list of all start parameters but no actual Eclipse. (No matter whether I use Java 8, 11, 14, or 19 here.) – Panossa Mar 13 '23 at 10:09
34

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'

BugaBuga
  • 489
  • 4
  • 10
21

Do this:
1. Go to the folder where eclipse is installed (the one that has the eclipse.exe program in)
2. Open the text file eclipse.ini with notepad or something similar
3. 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.

Ben Thurley
  • 6,943
  • 4
  • 31
  • 54
8

Many hints given already. Anyway I will just provide the recommended way of doing it which might help for future reviews of that question:

  1. Use the eclispe.ini file (folder where the eclipse binary resides)
  2. 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

  3. 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.
  4. The -vm option and its value (the path) must be on separate lines.
  5. The value must be the full absolute or relative path to the Java executable, not just to the Java home directory.

see: the eclipse.ini authoring guidelines from eclipse wiki

staiiir
  • 81
  • 1
  • 1
6

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!

Johny Jaz
  • 875
  • 2
  • 13
  • 26
  • 2
    Care to explain why? It's the recommended way so it should work. It doesn't bother me that you didn't use my answer. It's just misleading for anyone reading this question to say that none of the answers worked. – Ben Thurley Aug 29 '13 at 12:04
  • I'll add the error I get: Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit. – Marek Nov 06 '13 at 17:37
4

These two options worked for me on Windows:

  1. Edit eclipse.ini

    -vm
    
    C:/Java/jdk1.7.0_71/jre/bin
    
    -vmargs
    ...
    
  2. 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

Sabeesh
  • 41
  • 2
1

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.

PbxMan
  • 7,525
  • 1
  • 36
  • 40
1

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 
vani saladhagu
  • 162
  • 2
  • 13
0

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.