Reputation: 1703
I am trying to execute a java class file from php using the exec method. However, i get the following error.
I have set chmod 777 to the java class file so i suppose permission is not an issue.
For some reason it is not able to find it ?
I can run the java class file from the terminal using the java command without any problem
Error:
Error: Could not find or load main class .var.www.redbutton.readBashScript.class
<?php
exec('java /var/www/redbutton/readBashScript.class');
?>
and
<?php
exec('java /var/www/redbutton/readBashScript');
?>
Upvotes: 0
Views: 249
Reputation: 11949
The java exec does not work like that.
You need not pass the file to "execute", but the class which is why you get an error.
You must do:
java -cp /var/www/redbutton readBashScript
But:
/var/www/redbutton
must be a classpath directory, where your .class reside. Java will by default try to find classes in the current directory, which explains why it work in the console.readBashScript
must be the name of a class containing a main
method.Upvotes: 1