JDKs and IDEs Tips & FAQ
Running Multiple JDKs
To support multiple Java version, with ZSH:
1. Pick The Right JDKs with Right Versions
For example, we're going to have two JDKs, v8 and v11, with HotSpot installed.
$ export JDK8=adoptopenjdk8
$ export JDK11=adoptopenjdk11Or if OpenJDK with OpenJ9 (instead of HotSpot)
$ export JDK8=adoptopenjdk8-openj9
$ export JDK11=adoptopenjdk11-openj9Note: check the available versions here
2. Install Multiple Java Versions:
$ brew cask install ${JDK8}
$ brew cask install ${JDK11}3. Make then switchable, with a default version:
$ cat <<EOF >> ~/.zshrc
# Multiple Java Versions
export JAVA_8_HOME=$(/usr/libexec/java_home -v1.8)
export JAVA_11_HOME=$(/usr/libexec/java_home -v11)
alias java8='export JAVA_HOME=$JAVA_8_HOME'
alias java11='export JAVA_HOME=$JAVA_11_HOME'
#default java11
export JAVA_HOME=$JAVA_11_HOME
EOFNow, to switch versions, do this:
Note: as the process has nothing special, you may simply do it in
~/.bash_profiletoo with pure Bash env
IDE Failed To Start: failed to create java virtual machine.
Ref: https://gist.github.com/brightzheng100/20bd34c37367219340bdb359040370dd#file-sts-failed-to-start-md
Sometimes STS/Eclipse failed to start: failed to create java virtual machine.
It might be caused by multiple JDKs installed.
So we have to specify if it helps.
Note:
-vmmust be before-vmargs!
IDE with lombok support
lombok supportProject Lombok is cool, but it's not installed by default for most of the IDEs. So a simple installation process might be required.
For STS/Eclipse
We may download the
lombok.jarfrom here, or use the one in your~/.m2/repository/org/projectlombok/folder;Run
java -jar <THE-PATH-TO-YOUR-JAR>;It will prompt up an UI for you to pick up what IDEs (e.g. Eclipse, STS) to install for, choose yours;
Click install button and it's done.
Note: for STS/Eclipse, it will actually copy the jar file to IDE's folder and update its .ini file. For example, it adds below in
/Applications/STS.app/Contents/Eclipse/STS.inifile:
For VS Code
There is an addon we can install to make VS Code have lombok support. Search this addon by keyword lombok will do.
Last updated
Was this helpful?