gpt4 book ai didi

java - 在 IntelliJ 中执行程序/编译时出错,命令行中没有错误

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:20:49 24 4
gpt4 key购买 nike

我最近买了一台 Macbook Air,它现在正在运行 Mountain Lion,但我在运行公司的项目时遇到了一些问题,唯一一个在工作中使用 Mac 的人在他的 Macbook Pro 上运行 Lion,而他没有这样的问题。正如标题所说,在命令行上编译项目没有问题,但是当我尝试在 IntelliJ 中编译它时出现此错误

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (requireJS-Optimizer) on project MarfeelTouch: Command execution failed. Cannot run program "node" (in directory "/Users/pedrompg/Documents/Marfeel/MarfeelTouch"): error=2, No such file or directory -> [Help 1]

当我从命令行编译它并尝试运行程序时也会出现这个问题

Caused by: java.util.concurrent.ExecutionException: java.io.IOException: Cannot run program "phantomjs" (in directory "/Users/pedrompg/Documents/Tenants/vhosts/discoverint"): error=2, No such file or directory
at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:232) ~[na:1.6.0_35]
at java.util.concurrent.FutureTask.get(FutureTask.java:91) ~[na:1.6.0_35]
at com.marfeel.pressSystem.impl.SectionPressImpl.getAllItemsFromSectionFeeds(SectionPressImpl.java:137) ~[MarfeelPressSystem-1.0.jar:na]
... 29 common frames omitted

似乎我无法从项目内部运行任何命令行程序

这就是我们 phantomJS 调用的方式:

private Process buildProcess() throws IOException {
Process process;
String[] invocationCmd = getInvocationCmd();

if (executionDirectory != null) {
if (LOG.isDebugEnabled()) {
LOG.info("Invoking PhantomJS with {} in {}.", Arrays.toString(invocationCmd), executionDirectory);
}

process = Runtime.getRuntime().exec(invocationCmd, null,
new File(executionDirectory));
} else {
if (LOG.isDebugEnabled()) {
LOG.info("Invoking PhantomJS with {} in {}.", Arrays.toString(invocationCmd));
}

process = Runtime.getRuntime().exec(invocationCmd, null);
}

return process;
}

getInvocationCmd() 返回以下数组

[phantomjs,--load-images=no,--disk-cache=yes,--max-disk-cache-size=1048576,/Users/pedrompg/Documents/Marfeel/MarfeelHub/target/webapp/WEB-INF/classes/whiteCollar.js,marca/marca.js,http://www.marca.com/]

不知道有没有留下相关信息我们在项目上使用Maven、tomcat 7、nodeJS、phantomJS 1.5、nginx 1.2.4、java 1.6.0_35

希望有人能提供帮助,我真的很担心这个问题,已经浪费了 2 天时间来解决这个问题。

提前致谢

最佳答案

由于您使用的是 Mac,这很可能是与环境相关的问题。请注意,在 Mac 上,GUI 应用程序不会继承终端环境变量,因此,如果您调整了 PATH 变量并且命令在终端中运行,那么当您尝试从其他应用程序运行时,它将不起作用。

参见 related questions关于此 Mac 功能。关注second link , Mountain Lion 对环境变量有不同的行为。

验证是这种情况并解决问题的最简单方法是从终端运行 IntelliJ IDEA:

open -a /Applications/IntelliJ\ IDEA\ 11.app/

这样,终端环境将传递给 IDEA,您可以从终端运行的命令也将从 IntelliJ IDEA 运行。

关于java - 在 IntelliJ 中执行程序/编译时出错,命令行中没有错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12651107/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com