【问题标题】:Getting Java Compile Error in PHP在 PHP 中获取 Java 编译错误
【发布时间】:2013-10-07 22:41:15
【问题描述】:

我正在尝试获取 exec("some javaPath/javac", $output, $exit) 的编译错误。 我尝试了 print_r($output) 和 implode($exit) 但我注意到 print_r 如果编译失败会给出一个空错误,并且 implode 只给出错误代码。

有没有办法得到编译错误?例如,是否有可能得到哪一行有语法错误?

谢谢

【问题讨论】:

标签: java php compiler-construction compiler-errors javac


【解决方案1】:

显示$exit的值怎么样?

【讨论】:

    【解决方案2】:

    编译器可能将错误信息发送到错误流而不是标准输出。两者在终端/控制台窗口中的相同位置,但程序读取输出不会看到错误,反之亦然。

    你可以试试exec('some javaPath/javac 2>&1', $output, $exit);,看看它是否显示了更多信息。在 Linux 中,它应该。在 Windows 中,也许其他人知道...

    【讨论】:

    • var_dump 返回 string(0) "" 它不再添加信息。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-03
    • 2012-03-16
    • 2013-04-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多