A new job means a new development environment! Our wiki had us setting environment variables for JAVA_HOME, etc. tied to specific versions. I poked around to see if there’s a way to do that version-agnostically. Turns out there is! Especially if you use Homebrew to install your dependencies.
Need JAVA_HOME but don’t want a hardcoded location? /usr/libexec/java_home will give you the full path and the -v 1.(6|7|8) option will give it for whatever version you want. Adding it to your .bash_profile looks like export JAVA_HOME="$(/usr/libexec/java_home -v 1.8)".
Need (GRADLE|GROOVY|MAVEN)_HOME? Did you install and maintain it with Homebrew? They’re symlinked to /usr/local/opt/(gradle|groovy|maven)/libexec
Leave a comment