Java
Install and manage Java JDK versions using SDKMAN! for development and testing tools
What is Java?
Java is a high-level, class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible.
Java is a programming language and computing platform first released by Sun Microsystems in 1995. It has evolved from humble beginnings to power a large share of todayβs digital world, by providing the reliable platform upon which many services and applications are built.
Some of the tools used for testing mobile devices require Java, which you can download using SDKMAN!.
Prerequisites
Install Java Using SDKMAN! (Preferred)
Install the latest version of Java SE:
sdk install java
This will install the latest version based on Eclipse Temurin.
List all Java versions available:
sdk list java
This shows a table with:
- Vendor - The JDK provider (Corretto, GraalVM, Java.net, Liberica, Temurin, etc.)
- Use - Indicates if this version is in use
- Version - The Java version number
- Dist - Distribution identifier
- Status - Installation status
- Identifier - The identifier to use when installing
Install a specific version:
Use the
Identifiercolumn from thesdk list javaoutput to specify the version you want. Eclipse Temurin is a popular choice for JDK.
sdk install java <identifier>
Close your terminal session and add Java exports to your ~/.zshrc or ~/.bashrc
config file.
Switching JDK Versions
Set global version:
sdk default java <identifier>
Use version in current shell only:
sdk use java <identifier>
Check current version:
sdk current java
List installed versions:
sdk list java | grep "\*"
For more details on SDK version management, refer to the SDKMAN! foundation guide.
Troubleshooting
βjava: command not foundβ
-
Verify SDKMAN! is initialized:
sdk version -
Check Java is installed:
sdk list java | grep installed -
Set a default version:
sdk default java <identifier>
JAVA_HOME Not Set
Add to your ~/.zshrc:
export JAVA_HOME=$HOME/.sdkman/candidates/java/current
Then verify:
source ~/.zshrc
echo $JAVA_HOME
Wrong Java Version Being Used
Check whatβs controlling your Java:
# Which java is being used
which java
# Is there a .java-version or .sdkmanrc file?
ls -la .java-version .sdkmanrc 2>/dev/null
If a local file is overriding your global version, remove it or update it.
Certificate/SSL Issues
Some corporate networks require custom certificates. If you see SSL errors:
# Import certificate to Java keystore
keytool -import -trustcacerts -keystore $JAVA_HOME/lib/security/cacerts \
-storepass changeit -alias your-cert -file certificate.crt
Uninstalling
Check Installed Java Versions
/usr/libexec/java_home -V
Also check if Java is managed by SDKMAN:
sdk list java 2>/dev/null | grep installed
Remove JDK via SDKMAN
# list installed versions
sdk list java | grep installed
# uninstall a specific version
sdk uninstall java <version>
To remove SDKMAN itself and all its managed SDKs:
rm -rf ~/.sdkman
Remove the SDKMAN initialization from ~/.zshrc or ~/.bashrc:
# remove these lines
export SDKMAN_DIR="$HOME/.sdkman"
[[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ]] && source "$HOME/.sdkman/bin/sdkman-init.sh"
Remove JDK via Homebrew
brew list | grep -i "openjdk\|java\|temurin"
brew uninstall --cask --zap temurin
# or
brew uninstall openjdk
Remove Manually Installed JDKs (Oracle / OpenJDK)
JDKs installed via .dmg or .pkg installers are in
/Library/Java/JavaVirtualMachines/:
# list installed JDKs
ls /Library/Java/JavaVirtualMachines/
# remove a specific JDK
sudo rm -rf /Library/Java/JavaVirtualMachines/<jdk-name>.jdk
sudois required because/Library/Java/is a system directory owned by root.
Remove Java Plugins and Preferences
Remove the Java browser plugin and system preferences pane (if installed by Oracle JDK):
sudo rm -rf /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo rm -rf /Library/PreferencePanes/JavaControlPanel.prefPane
sudo rm -rf /Library/Application\ Support/Oracle/Java
Remove jenv (If Used)
brew uninstall jenv
rm -rf ~/.jenv
Remove jenv initialization from ~/.zshrc or ~/.bashrc:
# remove these lines
export PATH="$HOME/.jenv/bin:$PATH"
eval "$(jenv init -)"
Clean Up Shell Configuration
Remove any Java-related environment variables from ~/.zshrc or ~/.bashrc:
# remove lines like these
export JAVA_HOME=...
export PATH=$PATH:$JAVA_HOME/bin
Then reload your shell config or restart your terminal:
source ~/.zshrc # or source ~/.bashrc
Verify Removal
# should return "No Java runtime present"
java -version
# should return empty or "Unable to find any JVMs"
/usr/libexec/java_home -V
which javawill still resolve to/usr/bin/javaon macOS β this is a system stub, not an installed JVM. Usejava -versionand/usr/libexec/java_home -Vto confirm the JVM is removed.
Resources
Official introduction to Java from Oracle
Learn how to manage Java versions with SDKMAN!
Recommended open-source JDK distribution