简体   繁体   中英

How to call an executable jar from php with an argument passed to main method

I have created an executable jar and it works fine. For the testing purpose, I have used a dummy variable in the main method.

Instead, I need to pass a string variable, while calling this executable jar from php.

In short, I need to:

  1. Call the executable jar from PHP
  2. While calling the jar, I need to pass a string variable from PHP to the main method of the class inside executable jar.

How can I accomplish the aforesaid?

shell_exec("java -jar your_JAR.jar arg1 arg2");

您还可以通过使用exec而不是shell_execute来执行 Java,为它提供$output和 & $return_var变量(请参阅链接的手册页)并在调用后查看它们包含的内容。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM