1

enter image description here

I have been running STS4 on my MAC without trouble for some time, however I only had Oracle's JRE installed as shown below:

Java(TM) SE Runtime Environment (build 1.8.0_162-b12)

Yesterday I installed the OpenJDK 11 package using Brew. Now I (also) have OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.6+10)

After doing this, STS4 refuses to start with the error shown. I then 1. Uninstalled and then reinstall STS to get the most current version. Same error on start-up 2. Using suggestions from here, updated the SpringToolsSuite4.ini and attempted to add a -vm argument. This also did not work.

So...??? I'd like STS to use the 8 JDK as it's default and, as I want to, java projects can get set to 8 or 11 depending on things.

One other tidbit. Under System/Preferences window I only see the 8 JDK even though I have 8 and 11 installed, but I don't see a way to tell this setup preferences window to do that???

enter image description here

AstarAndy
  • 121
  • 1
  • 8
  • adding the -vm setting to the ini file should work. Can you paste the content of your modified ini file here? – Martin Lippert Mar 17 '20 at 08:25
  • I usually download the AdoptOpenJDK builds and add them to the VirtualMachines directory manually, so I am not sure if installing it via brew makes a difference here. But lets first take a look at the ini file. – Martin Lippert Mar 17 '20 at 08:28
  • --launcher.appendVmargs -vm /Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home/bin -startup ../Eclipse/plugins/org.eclipse.equinox.launcher_1.5.600.v20191014-2022.jar --launcher.library ../Eclipse/plugins/org.eclipse.equinox.launcher.cocoa.macosx.x86_64_1.1.1100.v20190907-0426 -product org.springframework.boot.ide.branding.sts4 --launcher.defaultAction openFile -vmargs -Dosgi.requiredJavaVersion=1.8 -Xms256m -Xmx1024m -XX:+UseG1GC -XX:+UseStringDeduplication --add-modules=ALL-SYSTEM -XstartOnFirstThread – AstarAndy Mar 17 '20 at 14:44
  • Agai, I was using JDK and was only starting on 11. It does appear that the system defauilt on the MAC is still 8 but MY default is now 11. – AstarAndy Mar 17 '20 at 14:46
  • I was also curious if it matters that the 8 JDK was from Oracle but the 11 is and AdaptOpenJDK version? Just curious if that matters any. – AstarAndy Mar 17 '20 at 14:48
  • keep in mind that the `-vm` option in the ini file has to be the first line, followed by the path to the java executable (including the executable) in the second line. After that, everything else follows. – Martin Lippert Mar 18 '20 at 09:55
  • more details can be found here: https://wiki.eclipse.org/Eclipse.ini – Martin Lippert Mar 18 '20 at 09:56
  • `Unbelievable!` – AstarAndy Mar 18 '20 at 17:59
  • If the first line is `-vm /some folder to java` then it will puke. On the other hand, if you have `-vm` on the first line and then the path on the `2nd` line it works just fine. – AstarAndy Mar 18 '20 at 18:00
  • So the fix is; -vm on the first line, then the actual path on the 2nd line. – AstarAndy Mar 18 '20 at 18:00
  • Appreciate it all – AstarAndy Mar 18 '20 at 18:00
  • glad to hear you got it working – Martin Lippert Mar 19 '20 at 18:03

2 Answers2

1

I am using SpringToolSuite4 on MacOS with JDK 11., tried different options to update vm to JDK path in /SpringToolSuite4.app/Contents/info.plist and /SpringToolSuite4.app/Contents/Eclipse/SpringToolSuite4.ini, none of them worked.

Finally here are the steps that worked for me.

1) Uninstall/Remove existing JDK folders. Existing JDKs can be found out by the following command.

$/usr/libexec/java_home -V


$rm -Rf /Library/Java/JavaVirtualMachines/java8 
$rm -Rf /Library/Java/JavaVirtualMachines/java11

2) Download JDK tar files instead of the installers.

https://download.java.net/openjdk/jdk11/ri/openjdk-11+28_linux-x64_bin.tar.gz

3) Extract the JDKs in to the usual installation folder.

sudo cp -R ~/Downloads/openjdk-8.0.252.9.1.jdk /Library/Java/JavaVirtualMachines/
sudo cp -R ~/Downloads//openjdk-11.0.7.10.1.jdk /Library/Java/JavaVirtualMachines/

4) Uninstall any existing STS from local which can be done by moving the STS to Trash(To remove any previous config changes which might interfere with the clean installation).

5) Restart the system to make it a clean installation.

6) Download latest STS 4 installer for Mac

7) STS installs without any issue

8) Start Installed STS and select workspace folder

9) When You start a new project both JDKs show up, select which ever JDK is required for the project.

10) Optional step Update ~/.bashrc or ~/.bash_profile with the JAVA_HOME and PATH similar as follows.

 export JAVA_HOME=/Library/Java/JavaVirtualMachines/openjdk-11.0.7.10.1.jdk/Contents/Home
 export PATH=$PATH:$JAVA_HOME/bin

You can execute $ source ~/.bash_profile to update the paths as per your needs to set the path.

kanaparthikiran
  • 523
  • 12
  • 15
0

I was able to resolve the issue by completing the following steps:

  1. Open SpringToolSuite4.ini file with a text editor.
  2. Add the following lines after openFile

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

    Your JDK version can be different than jdk1.8.0.241.jdk.
    Check your version and edit the line accordingly.

  3. Save the file and run STS4.

Azametzin
  • 5,223
  • 12
  • 28
  • 46