[英]php shell_exec executing java program
In PHP code I try to execute Java program using shell_exec but I get empty line. 在PHP代码中,我尝试使用shell_exec执行Java程序,但出现空行。
When I tried to execute program in bash: 当我尝试在bash中执行程序时:
#bin/bash
echo "aaa"
I get "aaa" but when i tried to execute the same file with 我得到“ aaa”,但是当我尝试执行相同的文件时
#bin/bash
java MainApp
I got empty line 我有空行
This is the java code 这是java代码
public class MainApp{
public static void main(String[] args)
{
System.out.print(":]");
}
}
When i do: 当我做:
#bin/bash
echo "aaa"
java MainApp
echo "bbb"
I get "aaa bbb" 我收到“ aaa bbb”
I wont to get ":]" string How to make it work? 我不会得到“:]”字符串如何使其工作?
Maybe printing line with System.out.println(String ) is not the same as echo and printing line is not the same as returning value 也许带有System.out.println(String)的打印行与echo不同,并且打印行与返回值不同
PHP command shell_exec() not working for my custom Java app5 PHP命令shell_exec()无法用于我的自定义Java应用程序5
There was the same problem :] 出现了同样的问题:]
I have used 我用过
echo shell_exec("/usr/bin/java MainApp"); 回声shell_exec(“ / usr / bin / java MainApp”);
and now it works :] I don't know why in bash there was problem with "java" command but now everything works fine :] 现在它可以工作了:]我不知道为什么在bash中“ java”命令有问题,但是现在一切正常:]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.