score:38

Accepted answer

edit the file /applications/eclipse.app/contents/info.plist

there is a comment for use a particular jvm:

<key>eclipse</key>
<array>
    <!-- to use a specific java version (instead of the platform's default) uncomment one of the following options,
        or add a vm found via $/usr/libexec/java_home -v -->
    <string>-vm</string><string>/library/java/javavirtualmachines/jdk8u192-b12/contents/home/jre/</string>
    <string>-keyring</string>
    <string>~/.eclipse_keyring</string>
</array>

score:0

i met this problem with eclipse-java-2020-03-m2-macosx-cocoa-x86_64, and opendjdk11. the latest eclipse installer at the moment also complained same error.

after i switched back to openjdk8, everything goes well...

score:0

for windows os:

  1. open eclipse.ini in the eclipse program folder
  2. add the below lines at the top of the file

-vm

path-to-java-bin\javaw.exe (for example: c:\program files\java\jdk-11.0.10\bin\javaw.exe)

score:1

delete all java folder inside /library/java

then install a new jdk from https://adoptopenjdk.net/

which will install at /library/java/javavirtualmachines/adoptopenjdk-8.jdk

then try reinstalling eclipse a

score:1

i had the same problem in my mac. here is my solution.

first: i've uninstall all the versions of jdk, because i've try a lot of options. to do this, you need to go to library/java/javavirtualmachines and delete all the folders.

second: install jdk 1.8 here is a link to download this version: jdk 1.8

third: install eclipse 2020-03 and thats all.

if you want to use jdk 14, you need to follow this steps:

  1. open eclipse
  2. go to help > install new software
  3. in the install window copy the following link in work with https://download.eclipse.org/eclipse/updates/4.15-p-builds/

install window

  1. select the third option show in the picture below option
  2. then, click "next" and finish the install

now you have to change the options, go to preferences (command + ,) > java > compiler and search the version 14. before this step you need to install jdk 14 (link) perhaps eclipse would suggest you to change to the correct jres, for this you need to go to java > installed jres and add the correct version. when you click add you need to choose he jre type, in my case i use a macos x vm and standard vm, then you have to choose the directory (/library/java/javavirtualmachine/jdk-14/contents/home and click open you could give a jre name and finish eclipse will be restart and now you can use eclipse with java 14.

enter image description here

this works for me, i hope you have understood me.

score:1

go to /library/java/javavirtualmachines

delete all version except one in use.

score:1

install jdk 8 from brew work for me. you can get the instruction on installing jdk 8 from homebrew here how to install java 8 on mac

score:2

referring to marseille joseph https://www.eclipse.org/forums/index.php?t=msg&th=1102885&goto=1823113&#msg_num_13 this worked for me!

their solution didn't require uninstalling jdk14 or to editing the eclipse.ini file. instead, do this:

cd /library/java/javavirtualmachines/jdk-14.jdk/contents/macos/
sudo rm /library/java/javavirtualmachines/jdk-14.jdk/contents/macos/libjli.dylib
sudo ln -s /library/java/javavirtualmachines/jdk-14.jdk/contents/home/lib/libjli.dylib libjli.dylib

score:2

i started facing the same problem in mac suddenly after updating to macos monterey, so i just did the following steps: enter image description here then go to contents/eclipse/eclipse.ini file and open it with any text editor and you will see the following: enter image description here add below line before -vmargs as shown in above image:

-vm  /library/java/javavirtualmachines/jdk1.8.0_171.jdk/contents/home/bin/java

this below line will be different for all the users:

/library/java/javavirtualmachines/jdk1.8.0_171.jdk/contents/home/bin/java

and you can just get this line copied to your clipboard using this command in terminal:

$ echo $(/usr/libexec/java_home)/bin/java | pbcopy

similarly will be for sts:

enter image description here then go to contents/eclipse/springtoolsuite4.ini as shown below and open with any text editor app. enter image description here

you will see the following: enter image description here just add the same line that you added for eclipse in the above steps: enter image description here

score:11

note: the error "failed to create the java virtual machine" also exists with eclipse 2020-03 (under some situations, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=561273) and it is not required to use java 8 (with eclipse 2020-03).

for the impatient:

you can run eclipse or the eclipse installer with a given vm without changing eclipse.ini by starting it via a command line:

  • open terminal an run:

  • open pathtoeclipseinstaller/eclipse\ installer.app --args -vm /library/java/javavirtualmachines/nameofjdk/contents/home/bin

where pathtoeclipseinstaller is the path of the folder where eclipse installer is located and nameofjdk is the name of the folder with the jdk (11, 12, 13).

for example:

open downloads/eclipse\ installer.app --args -vm /library/java/javavirtualmachines/jdk-11.0.2.jdk/contents/home/bin

in the installer you may select the vm used by eclipse. use a compatible vm here and the installer will modify the eclipse.ini for you.

explanation tl;dr

to clarify this issue:

eclipse - say eclipse 2020-03 - runs with java 11, java 12, java 13, but does not run with java 14. it fails with the message "failed to create the java virtual machine". this happens for the installer and for eclipse itself.

you can download eclipse without the installer from here: https://www.eclipse.org/downloads/packages/

explanation:

on macos, if you start a freshly installed eclipse, it will use the default jvm. the default jvm is obtained by running /usr/libexec/java_home.

this program /usr/libexec/java_home will find the installed jdk with the highest version as default. that is, if you have jdk 14 installed and run eclipse 2020-03, you will see this error.

solution

summarising some other answers here, there are three options:

  1. once you have removed jdk 14 from /library/java/javavirtualmachines/ the error will be gone.

  2. if you like to have jdk 14 installed, start the installer with a different jdk via the command line open path-to-eclipse-installer/eclipse\ installer.app --args -vm /library/java/javavirtualmachines/nameofjdk/contents/home/bin

  3. you may edit the eclipse.ini (as suggested in other answers) to use a specific jvm.

score:15

for me, i had to edit the eclipse-inst.ini file located here:

eclipse installer.app/contents/eclipse/eclipse-inst.ini

and add the path to my local java vm at the very top of the .ini file, which is here:

-vm
/users/bparks/jdk/jdk1.8.0_162_x64/bin/java

if the eclipse installer.app file is in a dmg, right click on it, and copy it, then paste it into another folder. then right click on that app file, and choose "show package contents", to get into the files inside the application.

if you've already got eclipse installed, and find it's throwing the same error, you could try a similar approach by editing the following file for eclipse:

/applications/eclipse.app/contents/eclipse/eclipse.ini

on mac, you can get the full path you'd need to your java exe by running the following in a terminal, which will copy the path to your clipboard.

$ echo $(/usr/libexec/java_home)/bin/java | pbcopy

score:23

it took me some time to figure this out as well. the main takeaway was eclipse does not support sdk version 14 (as of eclipse 2020-03). that was not completely obvious to me.

  1. install a supported version (i used homebrew to install sdk v8 🍺):

     brew cask install adoptopenjdk/openjdk/adoptopenjdk8
    

    if this is the only java version you have installed you should be fine and eclipse should open up. if that is not the case and you have another java version installed. you have to tell eclipse which version of java it should be using (see step 2).

  2. tell eclipse which version to use by editing the /applications/eclipse.app/contents/info.plist file as described by juan ignacio barisich and brad parks. that being the version you installed in step 1.

     nano /applications/eclipse.app/contents/info.plist
     # or
     open /applications/eclipse.app/contents/info.plist
    
     <key>eclipse</key>
     <array>
         <string>-keyring</string>
         <string>~/.eclipse_keyring</string>
         <string>-vm</string>
         <string>/library/java/javavirtualmachines/adoptopenjdk-8.jdk/contents/home/jre/</string>
     </array>
    

disclaimer: please bare in mind that those were the steps i took to get eclipse running again. because i'm nowhere qualified to give a precise answer about this please take a look at the comments in case i got something wrong.

edit: see christian fries answer who pointed out that all java versions 8 to 13 are supported by eclipse.


Related Query

More Query from same tag