I'm on OS X and have been using Java 1.8 from Oracle. In order to install mfp
I did have to install the old Java 6 from Apple, but it also seems certain mfp
commands, mfp build
at least, fail unless I change my JAVA_HOME
environment variable to point to the Java 6 installation.
Here's the output I see:
$ mfp build
[Error:
BUILD FAILED
/Applications/IBM/MobileFirst-CLI/mobilefirst-cli/node_modules/generator-worklight-server/lib/build.xml:133: The following error occurred while executing this line:
/Applications/IBM/MobileFirst-CLI/mobilefirst-cli/node_modules/generator-worklight-server/lib/build.xml:155: Class not found: javac1.8
Total time: 1 second]
Error: Sorry an error has occurred. Please check the stack above for details.
$ JAVA_HOME=/Library/Java/Home mfp build
All apps and adapters were successfully built.
$
What's the best way for me to override JAVA_HOME
for mfp
?
Should I edit /Applications/IBM/MobileFirst-CLI/mfp
?
(FYI, the "javac1.8 class not found" error is a known problem with Ant < 1.9, which I assume is bundled with the MobileFirst-CLI as I have Ant 1.9.4 on my system with my Java 1.8 installation.)
The best approach here is to have a simple wrapper script as mentioned previously. This keeps you safe from updates. Also, be sure to remove the PATH setting in "/etc/profile". Its quite simple...
In Bash:
#!/bin/bash
#--------------------------------------------------------------------
# Simple multi-MFP launcher script
# Karl Bishop <kfbishop@us.ibm.com>
#--------------------------------------------------------------------
#-- Set specific Java Runtime?
#export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home
#-- MFP Home directory for custom runtimes
MFP_HOME="${HOME}/dev/mobilefirst"
#-- Set specific Java Runtime
export PATH=$JAVA_HOME/bin:$PATH
echo "Using Java: ${JAVA_HOME}"
#-- Launch custom MFP
${MFP_HOME}/mobilefirst-cli/bin/mobilefirst-cli.js $@
In node...
#!/usr/bin/env node
//--------------------------------------------------------------------
// Simple multi-MFP launcher script
// Karl Bishop <kfbishop@us.ibm.com>
//--------------------------------------------------------------------
var spawn = require('child_process').spawn;
var MFP_HOME = process.env.HOME + "/dev/mobilefirst",
MFP_CMD = MFP_HOME+"/mobilefirst-cli/bin/mobilefirst-cli.js",
JAVA_HOME = "/Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home";
process.env['JAVA_HOME'] = JAVA_HOME;
process.env['PATH'] = JAVA_HOME+"/bin:" + process.env['PATH'];
console.log("Using Java:", CFG.JAVA_HOME); //-- Launch custom MFP
spawn( MFP_CMD, args, { stdio:'inherit' } );
Hope this helps.