drozwmi5440 2015-09-08 05:59
浏览 187

php exec java错误java未找到

Everybody who can use a command php exec to run a java. I have a problem on my coding to testing java.

$output = exec("java -version 2>&1");
echo $output;

When I run a script on web browser I found,

java: not found

How can I work with php exec java. P.S. I could run a command php java -version on a shell command.

Thanks in advance.

  • 写回答

1条回答 默认 最新

  • doudiao2335 2015-09-08 06:48
    关注

    As the error is saying, java is probably not installed on your system. You didn't specify an operating system but here is the output of java -version in ubuntu without java:

    x@y:~$ java -version
    The program 'java' can be found in the following packages:
     * default-jre
     * gcj-4.8-jre-headless
     * openjdk-7-jre-headless
     * gcj-4.6-jre-headless
     * openjdk-6-jre-headless
    Try: sudo apt-get install <selected package>
    

    As you can see it even tells you how to install java, the package I would suppose you need is default-jre so you can go ahead and run sudo apt-get install default-jre.

    As to being able to run php java -version that means you have a file named java in the current working directory which runs php (for some reason?).

    Of course you will have to research how to install java on your type of operating system, google is your friend here.

    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?