After reading some of the posts in this website related to exactly the same issue I've got, I found that none of them were giving me a successful result:
How to run a jar from a web server using PHP
Run Java class file from PHP script on a website
why exec('java -jar file.jar') dont work on browser but works on command line?
I'm using a Windows Server 2008 R2 datacenter, 64 bits, it's an EC2 instance from AWS. The command that I use to run my jar in a php file is exec, which works for any phyton script and normal .exe programs. But when it comes to a jar, it does nothing.
This is my code (my jar needs 5 parameters):
$script = "java -jar scripts/IDW.jar 5 none 2 values_grid values";
$result = exec($script, $output);
if ($result) {
print_r($output);
}
else {
echo "Failed";
}
echo "<br/>Result: ". $result;
The result I have is:
Failed
Result:
When I run the jar on console, it runs perfectly, but not from PHP, which means I am passing the right parameter values at the above Php code.
Java version: 1.7.0_51 and PHP version: 5.4.26
I would highly appreciate any comments on this.