我在OS X上,一直在使用Oracle的Java 1.8。为了安装mfp,我确实必须从Apple安装旧的Java 6,但是似乎某些mfp命令(至少mfp build)失败了,除非我将我的JAVA_HOME环境变量更改为指向Java。 6安装。

这是我看到的输出:

$ 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.
$


我为JAVA_HOME覆盖mfp的最佳方法是什么?
我应该编辑/Applications/IBM/MobileFirst-CLI/mfp吗?

(仅供参考,“ javac1.8 class not found”错误是Ant

最佳答案

最好的方法是拥有一个如前所述的简单包装脚本。这样可以确保您免于更新。另外,请确保删除“ / etc / profile”中的PATH设置。非常简单...

在Bash中:

#!/bin/bash
#--------------------------------------------------------------------
# Simple multi-MFP launcher script
# Karl Bishop <[email protected]>
#--------------------------------------------------------------------

#-- 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 $@


在节点中...

#!/usr/bin/env node
//--------------------------------------------------------------------
// Simple multi-MFP launcher script
// Karl Bishop <[email protected]>
//--------------------------------------------------------------------
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' } );


希望这可以帮助。

关于java - 强制MobileFirst-CLI使用Java 6的推荐方法?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30735125/

10-10 11:49