# JAVA\_HOME Location on a Mac is no longer reliable

**URL:** <https://forum.inductiveautomation.com/t/java-home-location-on-a-mac-is-no-longer-reliable/8040>\
**Category:** Ignition\
**Created:** [February 21, 2014, 3:10pm UTC](https://forum.inductiveautomation.com/t/java-home-location-on-a-mac-is-no-longer-reliable/8040 "2014-02-21T15:10:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mlangdon](https://avatars.discourse-cdn.com/v4/letter/m/d9b06d/32.png) [@mlangdon](https://forum.inductiveautomation.com/u/mlangdon)\
**Post date:** [February 21, 2014, 3:10pm UTC](https://forum.inductiveautomation.com/t/java-home-location-on-a-mac-is-no-longer-reliable/8040/1 "2014-02-21T15:10:53Z")

</div>

This comes directly from ignition.sh:

```auto
# OSX always places Java in the same location so we can reliably set JAVA_HOME
if ["$DIST_OS" = "macosx"]
then
    if [-z "$JAVA_HOME"]; then
        JAVA_HOME="/Library/Java/Home"; export JAVA_HOME
    fi
fi
```

As of at least OS X 10.9 (and I think a bit earlier), if you install the Oracle version of Java (which you must do if you want Java 7) the install location for Java is:

```auto
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
```

I’m not sure why `[-z "$JAVA_HOME"];` evaluates true in this case as “echo $JAVA\_HOME” yields the above path in my terminal (bash is far from my thing). In any case, modifying the shell script to use that path points Ignition at the 1.7 JRE.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [February 21, 2014, 4:39pm UTC](https://forum.inductiveautomation.com/t/java-home-location-on-a-mac-is-no-longer-reliable/8040/2 "2014-02-21T16:39:21Z")

</div>

This shell script is part of the JSW distribution… maybe we can check if they’ve got an updated vesion.

FWIW, the reliable way to get a value usable for JAVA\_HOME on OS X (as of 10.9 or Java 7, anyway, not sure about earlier) is to execute /usr/libexec/java\_home and use the result.

```auto
kevin-dev-mbp:~ kevin$ /usr/libexec/java_home 
/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home
```

I have this set in my ~/.profile

```auto
JAVA_HOME=$(/usr/libexec/java_home)
```

The wrapper’s shell script should probably do the same when JAVA\_HOME isn’t set.

---

<div class="post-metadata">

**Author:** ![mlangdon](https://avatars.discourse-cdn.com/v4/letter/m/d9b06d/32.png) [@mlangdon](https://forum.inductiveautomation.com/u/mlangdon)\
**Post date:** [February 22, 2014, 7:28pm UTC](https://forum.inductiveautomation.com/t/java-home-location-on-a-mac-is-no-longer-reliable/8040/3 "2014-02-22T19:28:50Z")

</div>

Looks like the main reason I am seeing this problem is that I downloaded the JRE for this machine which installs to the plug-in location, and which apparently no amount of export JAVA\_HOME="… will remedy the /usr/libexec/java\_home situation.

Lesson learned: always get the JDK even if you don’t plan to write a line of Java on that machine.
