41

I am not able to run eclipse on macOS Big Sur developers beta I am getting an error stating "Failed to create the java virtual machine". Is there any way to solve the error

Error pic

The java version I am running: The java version I am running is showed in the pic

greg-449
  • 109,219
  • 232
  • 102
  • 145
Aayush Agarwal
  • 421
  • 1
  • 4
  • 4

20 Answers20

70

I have the same issue. I solve it by opening /Applications/Eclipse.app/Contents/Info.plist and adding:

<string>-vm</string><string>/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home/bin/java</string>

inside

<key>Eclipse</key>
        <array>
            ADD HERE!
        </array>

Of course the "/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home/bin/java" value must be replaced with the actual path based on the JDK version you are using.

rsc
  • 10,348
  • 5
  • 39
  • 36
bytesgo
  • 709
  • 4
  • 3
  • 1
    Was that in the `` entry under `Eclipse` where there is a comment about this in the standard file? A bit more details about exactly where to put this would be useful. – greg-449 Jul 01 '20 at 07:47
  • 1
    yes. and u should replace the value with your own JAVA_HOME – bytesgo Jul 02 '20 at 09:12
  • 1
    Mine is /Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home/bin/java Tried, does not work. Yes, I put it in the array of Eclipse key. – Lim Thye Chean Jul 03 '20 at 02:42
  • 4
    Mine is "jdk1.8.0_171.jdk". So I have added, following line -vm/Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home/bin/java. It worked. Thanks. – Arun Nov 14 '20 at 04:12
20

TL;DR

Use this to export JAVA_HOME variable:

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_231.jdk/Contents/Home

Long Version

This answer is wrt to BigSur v11.0.1 Beta. What I explored is if you have configured your .bash_profile JAVA_HOME export something like this

export JAVA_HOME=$(/usr/libexec/java_home)

Then it case it was trying to importing this, for some reason

/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home

rather than

/Library/Java/JavaVirtualMachines/**/Contents/Home

For the quick fix, I configured my JAVA_HOME like this

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_231.jdk/Contents/Home

If you are switching between multiple JVMs at once then you may find this .bashrc/.zshrc configuration handy

    export JAVA_8_HOME="jdk1.8.0_231.jdk"
    export JAVA_11_HOME="openjdk-11.0.2.jdk"
    export JAVA_13_HOME="jdk-13.0.1.jdk"
    
        
    alias java8='export JAVA_HOME="/Library/Java/JavaVirtualMachines/$JAVA_8_HOME/Contents/Home"'
    alias java11='export JAVA_HOME="/Library/Java/JavaVirtualMachines/$JAVA_11_HOME/Contents/Home"'
    alias java13='export JAVA_HOME="/Library/Java/JavaVirtualMachines/$JAVA_13_HOME/Contents/Home"'
    
    # default to Java 8
    java8
poke19962008
  • 714
  • 1
  • 9
  • 13
  • 1
    Is it a bug that the /usr/libexec/java_home was not point to a correct JDK like before? – civic.LiLister Nov 23 '20 at 03:12
  • 1
    This should be the accepted answer, just a quick note: You should check your installed java version by running `java -version` and updating the export path accordingly. In my case I switched `jdk1.8.0_231.jdk` for `jdk1.8.0_202.jdk` – Franco Mar 29 '21 at 18:10
  • I don't think this solves the issue with Eclipse / STS. This will work for all commands and the command line running in a shell. – jediwompa Dec 02 '21 at 21:34
12

Edit the Info.plist to set the -vm value.

  1. Install the latest Eclipse version, I am using version 2020-06
  2. Right-click on Eclipse.app
  3. Show Package Contents
  4. Open Info.plist with a text editor
  5. Add -vm/Library/Java/JavaVirtualMachines/jdk1.8.0_191.jdk/Contents/Home/bin/java under the under the key Eclipse. Note - edit the path to Java depending on what version you have. You can see the list by running /usr/libexec/java_home -V

enter image description here

Michael Peterson
  • 10,383
  • 3
  • 54
  • 51
  • 1
    It helped to resolve the issue. Steps are very detailed, thanks. – MagicWorld Oct 08 '21 at 17:31
  • This is the correct answer. For me specifically, I had to add `-vm/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/bin/java` . There is even an example in the `*.plist` file – jediwompa Dec 02 '21 at 21:40
6

To fix this issue I deleted the openJDK VM and reinstalled it

  1. Delete the openJDK folder from

    /Library/Java/JavaVirtualMachines

  2. Reinstall openJDK from here

  3. Open applications and right-click spring suite > Show Package Contents

  4. Edit file Contents/info.plist. Add this

<string>-vm</string><string>/Library/Java/JavaVirtualMachines/adoptopenjdk-14.jdk/Contents/Home/bin/java</string>

This should be inside the array tag inside eclipse key

enter image description here

umunBeing
  • 514
  • 1
  • 5
  • 15
3

I solved this by using Homebrew

brew cask install eclipse-java

martin
  • 2,150
  • 1
  • 34
  • 48
3

Same thing happened to me turns out when I ran echo $JAVA_HOME the directory has been replaced,

Doing a brand new export to the java home file seemed to do the trick, I used

export JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/

Seemed to do the trick, note that your directory might be different I suggest tracing to your correct directory by using "/" then tab to trace the directories.

2

enter image description here

In my case I'm using a old version IDE and it's dead, already add the JAVA_HOME variable, ini and list of eclipse and not working, also noticed virtualbox is dead also can start any VM.

-vm/Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk/Contents/Home/bin/java

1

Confirmed, adding below to Infolplist worked. I have Oracle jdk 8 and updated the value below. -vm/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/bin/java

Gurvinder
  • 11
  • 1
  • Can you explain what you mean with **infoIplist**? – Timo Nov 20 '20 at 11:39
  • i missed to read this, have you solved this. For infoplist read above response from @Michael Peterson. https://stackoverflow.com/a/63267200/3482387 – Gurvinder Nov 25 '20 at 18:08
1

I tried all solutions posted under this question; but none of them worked for me. Finally, I installed the latest version of Eclipse 2020-09 (4.17.0) to make it work.

1

I upgraded to Big Sur a few days ago and also encountered this problem when I finally ran Eclipse this morning.

The latest Eclipse 2020-12 release includes its own JRE (!), thus I no longer experience "Failed to create the java virtual machine". I've left my Java versions unchanged for now as I only use Eclipse to create Tomcat webapps and do not run standalone Java.

$ /usr/libexec/java_home 
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home

$ /usr/libexec/java_home -V
Matching Java Virtual Machines (3):
    1.8.121.13 (x86_64) "Oracle Corporation" - "Java" /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
    1.8.0_121 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home
    1.7.0_60 (x86_64) "Oracle Corporation" - "Java SE 7" /Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
Ken Lin
  • 1,819
  • 21
  • 21
1

In addition to all steps recommended above I had to create the following symlink:

    cd /Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home/lib
    sudo ln -s ../jre/lib/server/libjvm.dylib libserver.dylib

The version of the Eclipse I use is 4.4.1. (because tested to work well with WebObjects)

Georg Tuparev
  • 441
  • 2
  • 6
  • 11
1

I had to install the latest version of Eclipse to make it work since that uses Java 11. This happened after I updated to Big Sur.

Ankur Srivastava
  • 855
  • 9
  • 10
1
  • Step 1 : Uninstall jdk 8
  • Step 2 : Install openjdk14 by brew
  • Step 3 : install eclipse 2020-12 version
Slava Rozhnev
  • 9,510
  • 6
  • 23
  • 39
1

I deleted all Eclipse files that were already installed and just simply reinstalled with this --cask eclipse-jee on Home brew. I hope it's helpful for whoever is struggling just like past myself.

DANBI
  • 11
  • 1
1

I experienced this issue while using Eclipse Mat and JDK Mission Control On Mac OS v11.6 (Big Sur ) ,the dependency was Java 11 . The following was added in the whatever.app/Contents/Info.plist

<key>Eclipse</key>
<array>
     <string>-vm</string
      <string>/Users/<yourHomeDir>/.sdkman/candidates/java/11.0.2-open/bin/java</string>
      <string>-keyring</string>
      <string>~/.eclipse_keyring</string>
</array>
Alferd Nobel
  • 3,185
  • 2
  • 30
  • 35
0

If you are using eclipse 2020-06 sure you will be facing pop-up with empty grey window when debugging. No chance to use Big Sur with eclipse 2020-06 anymore. I'm using eclipse 2021-03 IDE developer and it's working fine. But STS not support anymore you have to manual change to old JAVA 1.8 for your project.

  1. Right click project and properties
  2. Configure Java Build Path
  3. Libraries Tab -> Edit -> change to Java 1.8
  4. Order and Export Tab -> move JRE System Library on top of Project and External Dependencies.

enter image description here

anson
  • 1,436
  • 14
  • 16
0

Apart from the suggestions given, I also had to do an additional step of removing eclipse app from quarantine :

1)Open up a shell

2)Cd yourself into the eclipse directory.

3)Check the attributes of the directory Eclipse.app/ $ xattr Eclipse.app/ com.apple.quarantine

4)Remove the ‘com.apple.quarantine’ attribute. $ xattr -d com.apple.quarantine Eclipse.app/

After completing this along with steps to edit the Info.plist, I was able to open Eclipse

Vasanth Raghavan
  • 162
  • 2
  • 12
0

Setting-security&privacy->Full Disk Access, add eclipse or Spring Tool Suite app.

0

brew install openjdk

add to /Applications/ApacheDirectoryStudio.app/Contents/Info.plist <dict>
<array>: 

<string>-vm</string>
<string>/usr/local/opt/java/libexec/openjdk.jdk/Contents/Home/bin/java</string>
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 29 '22 at 01:48
0

On Mac system follow the below step- In terminal and type "open /Applications/Eclipse.app/Contents/" Double click on "Info.plist"

<key>Eclipse</key>
<array>
<string>-vm</string><string>/Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home/bin/java</string>

use this line of code. May sure to uncomment the line of code. Sometime it is commented by default.