Last Updated: February 25, 2016
· helmedeiros

${env.JAVA_HOME}: maven, intelliJ IDEA and Mavericks


When running a maven goal from IDEA (12 or 13) that includes setting the -source and -target of the Java Compiler I am getting the following error.

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project <project name>: Compilation failure
[ERROR] Failure executing javac, but could not parse the error:
[ERROR] /bin/sh: ${env.JAVA_HOME}/bin/javac: bad substitution


Maven properties are value placeholder, like properties in Ant. Their values are accessible anywhere within a POM by using the notation ${X}, where X is the property. They come in five different styles, all accessible from the settings.xml file:

env.X: Prefixing a variable with "env." will return the shell's environment variable. For example, ${env.PATH} contains the $path environment variable (%PATH% in Windows).

By default, OSX has number of ways of setting environment variables. Most of us we're used to set them using terminal approach, you can set system wide and user specific environment variables, however they will be only visible in terminal, or by applications started from them.

THE Solution:

Environment variables set in launchd will be available to all programs on the system. However since $HOME/.launchd.conf is not supported, this approach is used for global environment variables only.

The /etc/launchd.conf file contains a list of commands to be run by launchctl during startup. However environment variables set in /etc/launchd.conf cannot have spaces and cannot reference other environment variables; launchctl when run in Terminal does not suffer these limitations.

Do note that /etc/launchd.conf does not exist by default, so we will need to create it.

  1. Open a terminal prompt

  2. Type: sudo nano /etc/launchd.conf

  3. Put contents like the following into the file:


  4. Apply changes: launchctl < /etc/launchd.conf

  5. Check if everything is okay: launchctl export

Say Thanks
Filed Under