Skip to content

Instantly share code, notes, and snippets.

@llipe
Last active August 27, 2020 20:06
Show Gist options
  • Save llipe/d5f18c39f137636a0ab9a8a83debc2d3 to your computer and use it in GitHub Desktop.
Save llipe/d5f18c39f137636a0ab9a8a83debc2d3 to your computer and use it in GitHub Desktop.

How to Setup a Java Development Environment on MacOS

Ref: https://dev.to/blacksourcez/setup-java-development-environment-for-macos-2pdg

Official Reference: https://github.com/jenv/jenv

Basic Install

# Requires homebrew -> https://brew.sh/
brew tap adoptopenjdk/openjdk

# javc 8
brew cask install adoptopenjdk8

# java 11
brew cask install adoptopenjdk11

# gradle
brew install gradle

# maven
brew install maven

Setup Java Env (jenv)

brew install jenv

jenv add /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
jenv add /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home

$ jenv
jenv 0.5.4
Usage: jenv <command> [<args>]

Some useful jenv commands are:
   commands    List all available jenv commands
   local       Set or show the local application-specific Java version
   global      Set or show the global Java version
   shell       Set or show the shell-specific Java version
   rehash      Rehash jenv shims (run this after installing executables)
   version     Show the current Java version and its origin
   versions    List all Java versions available to jenv
   which       Display the full path to an executable
   whence      List all Java versions that contain the given executable
   add         Add JDK into jenv. A alias name will be generated by parsing "java -version"

See `jenv help <command>' for information on a specific command.
For full documentation, see: https://github.com/jenv/jenv/blob/master/README.md
➜  ~

To check available java versions

jenv versions
* system (set by /Users/felipemallea/.jenv/version)
  11
  11.0
  11.0.8
  openjdk64-11.0.8

To debug...

jenv doctor
[OK]	JAVA_HOME variable probably set by jenv PROMPT
[OK]	Java binaries in path are jenv shims
[OK]	Jenv is correctly loaded

Work in progress

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment