score: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.

score: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.

score: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 

score: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

score: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!

score: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

score:20

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.

score:32

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'

score:81

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


Related Query

More Query from same tag