How To Install Java 7 on Mac OS X

For most, this would come in handy with those using the lat­est brows­er exten­sion­s/add-ons that use Java, espe­cial­ly ver­sion 7 (in the time of this writ­ing). There are two ways to go about this. First, for most users, they just need the JRE. The sec­ond are those doing devel­op­ment work and need the JDK.

Before we start the instal­la­tion process, let’s start with some pre­flight check and do the fol­low­ing in Ter­mi­nal prompt:

$ java -version

This will give you 1.6.x of some degree. Now, let’s start the instal­la­tion.

If you just need the JRE:

  1. Down­load the JRE here.
  2. Fol­low the instruc­tions, and install onto your OS X sys­tem.
  3. In your ~/.profile,1 add the fol­low­ing:
    export JAVA_HOME="/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home"
    
  4. Open a new Ter­mi­nal win­dow, and run the fol­low­ing to check you are run­ning the intend­ed ver­sion:
    $ java -version
    

    This should give you some­thing like the fol­low­ing results:

    $ java -version
    java version "1.7.0_67"
    Java(TM) SE Runtime Environment (build 1.7.0_67-b01)
    Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)
    

For those that need the JDK, and run­ning Home­brew, you may do the fol­low­ing:

  1. Down­load the JDK here.
  2. Install jenv via Home­brew:2
    $ brew tap jenv/jenv
    $ bre install jenv
    

    More info here.

  3. Add the fol­low­ing in your Bash files by run­ning these in Ter­mi­nal:3
    $ echo 'export PATH="$HOME/.jenv/bin:$PATH"' >> ~/.profile
    $ echo 'eval "$(jenv init -)"' >> ~/.profile
    
  4. Con­fig­ure jenv by run­ning the fol­low­ing for exam­ple:
    $ jenv add /Library/Java/JavaVirtualMachines/jdk17011.jdk/Contents/Home
    oracle64-1.7.0.11 added
    
  5. Last but not least, check that you are run­ning the intend­ed ver­sion in Ter­mi­nal:
    $ java -version
    

I hope that helps.

  1. Or .bashrc, .bash_profile, etc. []
  2. Be sure to brew udpate and run brew doc­tor before adding any new pack­ages, always. []
  3. Again, these can be .bashrc, .bash_profile, etc. []

Comments are currently closed.