Mac / JAVA_HOME is not defined correctly

Since upgrading to 4.9.2 on Mac, launching Android applications fails with the following error:

LogPlayLevel: Error: JAVA_HOME is not defined correctly.
LogPlayLevel:   We cannot execute $(/usr//java_home)/bin/java
LogPlayLevel: BuildCommand.Execute: ERROR: BUILD FAILED
LogPlayLevel: Program.Main: ERROR: AutomationTool terminated with exception:
LogPlayLevel: Program.Main: ERROR: Exception in UnrealBuildTool: ERROR: /bin/sh failed with args -c '"/Developer/Android/apache-ant-1.8.2/bin/ant" -quiet debug'
LogPlayLevel: Stacktrace:   at UnrealBuildTool.Android.UEDeployAndroid.RunCommandLineProgramAndThrowOnError (System.String WorkingDirectory, System.String Command, System.String Params, System.String OverrideDesc, Boolean bUseShellExecute) [0x00000] in <filename unknown>:0
LogPlayLevel:   at UnrealBuildTool.Android.UEDeployAndroid.MakeApk (System.String ProjectName, System.String ProjectDirectory, System.String OutputPath, System.String EngineDirectory, Boolean bForDistribution, System.String CookFlavor, Boolean bMakeSeparateApks, Boolean bIncrementalPackage, Boolean bDisallowPackagingDataInApk) [0x00000] in <filename unknown>:0
LogPlayLevel:   at UnrealBuildTool.Android.UEDeployAndroid.PrepForUATPackageOrDeploy (System.String ProjectName, System.String ProjectDirectory, System.String ExecutablePath, System.String EngineDirectory, Boolean bForDistribution, System.String CookFlavor, Boolean bIsDataDeploy) [0x00000] in <filename unknown>:0
LogPlayLevel:   at AndroidPlatform.Deploy (AutomationTool.ProjectParams Params, DeploymentContext SC) [0x00000] in <filename unknown>:0
LogPlayLevel:   at Project.Deploy (AutomationTool.ProjectParams Params) [0x00000] in <filename unknown>:0
LogPlayLevel:   at BuildCookRun.DoBuildCookRun (AutomationTool.ProjectParams Params) [0x00000] in <filename unknown>:0
LogPlayLevel:   at BuildCookRun.ExecuteBuild () [0x00000] in <filename unknown>:0
LogPlayLevel:   at BuildCommand.Execute () [0x00000] in <filename unknown>:0
LogPlayLevel: Program.Main: AutomationTool exiting with ExitCode=Error_Unknown
LogPlayLevel: Domain_ProcessExit
LogPlayLevel: Completed Launch On Stage: Deploy Task, Time: 4.042335
LogPlayLevel: RunUAT ERROR: AutomationTool was unable to run successfully.
PackagingResults:Error: Error Launch failed! Unknown Error

JAVA_HOME is defined as
export JAVA_HOME=$(/usr//java_home)

And invoking command from the shell works fine:

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home

Hey Devel.bmad,

Please go to this [link][1] and make sure you click on the Mac OS button towards the top portion of the page. Since you are on a Mac, you need to make sure that you have Java 6 and Java 7 installed on your computer. Once you follow all of the steps on the documentation page, you should no longer run into this Java complication.

Please let me know if you have any further questions or concerns, thanks!

https://docs.unrealengine.com/latest/INT/Platforms/Android/GettingStarted/1/index.html

It actually has nothing to do with Java 6/7 being installed, it has to do with how Unreal’s buildchain handles environment variables. If you define it as:

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home

It will work as expected.