Tuesday, October 6, 2015

El Capitan, Homebrew and Java

It's a good idea to upgrade to El Capitan.

As usual, with major updates things break.

In this post we'll look at how to get homebrew and Java functioning properly.

Java

The first thing you may notice is that any application you use, e.g., IntelliJ, that require Java does not work.

Let's fix that by updating Java for El Capitan.

Go Here and click the Download button

Java for OS X 2015-001

After the javaforosx.dmg file is downloaded into your ~/Downloads folder, just double click it from the Finder and follow all the prompts to install it.

Update Java

Next, you'll want to go to your system preferences and update Java:




Now, you can verify it and see where El Capitan puts Java:




Jenv

If you're like me and use jenv, you'll need to update that, too.

Note: jEnv is a command line tool to help you forget how to set the JAVA_HOME environment variable.

brew info jenv - Error

If you get an error like the following when attempting to run brew info...


$ brew info jenv
jenv: stable 0.4.3 (bottled), HEAD
Manage your Java environment
http://www.jenv.be
/usr/local/Cellar/jenv/20130917 (62 files, 260K) *
  Built from source
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/jenv.rb
==> Caveats
To enable shims and autocompletion add to your profile:
  if which jenv > /dev/null; then eval "$(jenv init -)"; fi

To use Homebrew's directories rather than ~/.jenv add to your profile:
  export JENV_ROOT=/usr/local/opt/jenv
~ $ brew update
error: unable to unlink old '.travis.yml' (Permission denied)
Error: Failure while executing: git pull --ff --no-rebase --quiet origin refs/heads/master:refs/remotes/origin/master


Fix Permissions

... then you should fix the permissions in the /usr/local directory:


sudo chown $(whoami):admin /usr/local && sudo chown -R $(whoami):admin /usr/local


Note that the previous commands will fix a good number of other homebrew issues.

Update jenv shim

You'll want to update line 21 in $HOME/.jenv/shims/java

For me, I had to change this...


exec "/usr/local/Cellar/jenv/20130917/libexec/libexec/jenv" exec "$program" "$@"


...to this:


exec "/usr/local/Cellar/jenv/0.4.3/libexec/libexec/jenv" exec "$program" "$@"


Set Global jEnv Java Version

If you see this...


$ jenv versions
jenv: version `oracle64-1.6.0.65' is not installed
  system
  oracle64-1.7.0.75
  oracle64-1.8.0.31


... then, run this:


$ jenv global oracle64-1.8.0.31

$ jenv versions
  system
  oracle64-1.7.0.75
* oracle64-1.8.0.31 (set by /Users/lex/.jenv/version)


Check Java Version

Finally, you can verify that Java is now happy:


$ java -version
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)


Brew

Homebrew needs some love, too.

Just keep running brew update and doing what it says until you see this:


$ brew update
Already up-to-date.


Then, run brew doctor to be sure you're all good with brew:


$ brew doctor
Your system is ready to brew.


References

Java for OS X 2015-001 jEnv

This work is licensed under the Creative Commons Attribution 3.0 Unported License.

1 comment:

  1. Very helpful, thanks!

    I couldn't get the Java control panel to verify the location, but did eventually get the jenv part of my $PATH working and now Solr launches. So I am a happy camper.

    ReplyDelete