为什么EXEC('Java的罐子file.jar')不要浏览器的工作,但工作在命令行? [英] why exec('java -jar file.jar') dont work on browser but works on command line?
问题描述
我尝试从一个php文件是这样运行的jar:
I try to run an jar from an php file like this:
exec("java -jar /home/florinbuda/NetBeansProjects/monkey1/dist/monkey1.jar", $result);
print_r($result);
和它的作品,如果我运行它的命令行,如:
and IT WORKS if I run it from command line like:
$ php runner.php
但如果我尝试通过HTTP的本地主机服务器进行加载/ runner.php的页面只是不断加载永远不给任何错误这是行不通的。
but it doesn't work if I try to load it via http-localhost-server/runner.php the page just keeps loading forever without giving any error..
在.jar文件我添加了一个简单的测试,现在如果瓶子甚至开始工作。
In the .jar file I added a simple test to now if the jar is even started to work
public static void main(String[] args) {
new File("/home/florinbuda/Desktop/xxx").mkdir();
和,你可以猜到 - 当我打电话HTTP的本地主机服务器/ runner.php罐子甚至没有开始执行...
and as you can guess - when I call http-localhost-server/runner.php the jar is not even started to be executed...
这是权利的问题?你有什么建议吗?
It's a problem of rights? What suggestions do you have?
推荐答案
是的,这是许可的问题。
Yes, it's the problem of permission.
您应该搭配chmod .jar文件的父文件夹。
You should chmod the parent folder of .jar file.
chmod 755 -R /home/florinbuda/NetBeansProjects/monkey1/dist/
编辑:,然后你的脚本应该是这样的:
And then your script should look like this:
exec("PATH_TO/java -jar /home/florinbuda/NetBeansProjects/monkey1/dist/monkey1.jar");
这篇关于为什么EXEC('Java的罐子file.jar')不要浏览器的工作,但工作在命令行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!