Help Executing a jar file
Posted: Sat Sep 02, 2006 2:24 am
Hello, I am glad to be on the forums, but please have patience with me, because i just started learning PHP
So, here is the situation: I would like to have a php "script" that executes a jar file that produces a text file. Once the text file is produced, another PHP script reads the file, and displays it in HTML. I created the jar, and both scripts, but i cannot get them to work properly.
- If i manually add the text file, then the read scrip works perfectly, so there is nothing wrong with that.
- if i launch the jar file from the terminal with the linux terminal command java -jar /var/www/html/JarFolder/test3.jar then the jar is successfully executed, and the text file is created. Also, the jar file, and its entire directory has full read, write, and execute privileges for all users
- if i use my run script, however, the jar file does not execute and the text file is never produced
I would appreciate any help, so that i can fix this problem. Thanks
Here is my run script:
ps- if i copy the output of the last echo statement in the code above into my linux terminal and hit enter, the jar file executes fine, so its not a syntax error...
So, here is the situation: I would like to have a php "script" that executes a jar file that produces a text file. Once the text file is produced, another PHP script reads the file, and displays it in HTML. I created the jar, and both scripts, but i cannot get them to work properly.
- If i manually add the text file, then the read scrip works perfectly, so there is nothing wrong with that.
- if i launch the jar file from the terminal with the linux terminal command java -jar /var/www/html/JarFolder/test3.jar then the jar is successfully executed, and the text file is created. Also, the jar file, and its entire directory has full read, write, and execute privileges for all users
- if i use my run script, however, the jar file does not execute and the text file is never produced
Here is my run script:
Code: Select all
<html>
<head>
<title>Jar File Runner</title>
</head>
<body>
<?php
echo "<h2>Jar File Status</h2>";
$JarName = "test3.jar"; /tthis is the name of the file, unfortunately i have already checked and it is correct
$Path = getcwd();
$Command = 'java -jar ' . $Path . "/" . $JarName;
exec($Command);
echo " - The Jar File <i>" . $JarName . "</i> is running", "<br>", " - <a href='View.php'>View Output</a>";
echo "<br><br><i>Command Executed:</i>", $Command;
?>
</body>
</html>