我使用的是 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.
$
为 mfp
覆盖 JAVA_HOME
的最佳方法是什么?
我应该编辑 /Applications/IBM/MobileFirst-CLI/mfp
吗?
(仅供引用,“javac1.8 class not found”错误是 Ant < 1.9 的一个已知问题,我假设它与 MobileFirst-CLI 捆绑在一起,因为我的系统上安装了 Java 1.8 并安装了 Ant 1.9.4。)
最佳答案
此处最好的方法是使用前面提到的简单包装器脚本。这使您免受更新的影响。另外,一定要删除“/etc/profile”中的 PATH 设置。很简单...
在 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 $@
在节点中...
#!/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' } );
希望这对您有所帮助。
关于java - 强制 MobileFirst-CLI 使用 Java 6 的推荐方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30735125/