Set up JAVA_HOME to track Java Preferences.app on Mac OS X

/Applications/Utilities/Java Preferences.appMac OS X’s Java Preferences.app has a pane for switching between versions of the JDK, but I just found out from a coworker (thanks, Mike!) that you can make your shell match that preference easily — just add this to your ~.bashrc:

export JAVA_HOME=$(/usr/libexec/java_home)

If you change your JDK priority preference, you’ll need to re-source your ~/.bashrc or just open a new terminal window.

Related posts:

  1. HOWTO install etherpad on ubuntu 9.10
    Etherpad was opensourced by google, and has some generic installation instructions. Here’s the translation for Ubuntu Karmic Koala (release 9.10): Install the prerequisites: sudo apt-get install mysql-server-5.1 mercurial sun-java6-jdk sun-java6-jre......
  2. Java for Mac OS X 10.5 Update 1 adds support for Java SE 6
    Java for Mac OS X 10.5 Update 1 adds support for Java SE 6 Update: Apple’s java6 port can’t run IDEA… Back to java5. :-\......
  3. Make OpenOffice the default “.doc” and “.xls” application on Mac OS X
    OpenOffice 3.0 is now out for the Mac. Finder opens files that end in “.doc” with TextEdit by default, and “Open with…” doesn’t seem to stick. What to do? In......
  4. HOWTO: Configure an Amazon RDS instance to use UTF-8
    RDS has been working out pretty well for AdGrok — it’s a one-click MySQL 5.1 instance that seems pretty promising: Automatic replication and failover to another deployment zone (colo) Easy......