Hi I have Jar file which does some modifications to ZIP files. I want to execute the jar file by using PHP. I wrote like this code: <?php shell_exec('java -classpath testsign.jar testsign test.zip test2.zip'); ?> PHP: The jar file: testsign.jar After executing the jar file, It will modify test.zip and create the modified file test2.zip. I tried this code in AppServ and it worked. so I uploaded it to my website and I tried it but it didn't work. It doesn't create test2.zip I turned off the Safe Mode and made the chmod is 777. But didn't work. What the problem?? P.S: My hosting from Servage : http://www.servage.net Thanks
Try putting an echo before the shell_exec and see if it's telling you something useful (like an error).
could try the system() cmd php could also be wrapping the command differently to appserv, the echo of the output would be helpful on debugging
I tried system() and it's worked in appserv but didn't worked in my hosting. how can I put the echo of the output? Sorry I'm still beginner in PHP. And I have another question. If the hosting doesn't support JSP. Will the code work? Thanks
Onsome shared hosting shell_exec() is disabled using the php.ini disabled_functions, check your php.ini and edit it if you have access (or contact your host). To check if its its disabled or not use the following code: <?php if (function_exists('shell_exec')){ echo "Enabled"; } else { echo "Disabled"; } ?> PHP:
There doesn't need to be a problem with the code to produce an error. There could be a problem with the environment. Considering how low servages prices are, I'm thinking they've got their servers stripped down pretty thin. I'm guessing that either the server doesn't have Java installed, or it's not configured in a way that individual accounts can use it like that. Have you tried executing a different jar file, for instance a simple "hello world" type jar ?
I tried "hello world". But it doesn't work too. I think Servage doesn't support java. Do you know and hosting company support java?
The VPS is too expensive for me. The java file's work is to encrypt some files with a private key. Can I do that with php directly?
You first need to find out for sure if the server you are running on has Java installed so you can run Java programs, check the informaion from the hosting company. Assuming not, as it's usually mentioned specifically when you subscribe, you'd need to switch your account. There are good hosting solutions avalable that allow you to do everything common to PHP hosting and Java on top for less than 10$ a month. And if you just want to run Java programs on your server account you don't need a VPS, a shared server account is plenty. The providor i use has a basic VPS with Java for 9.90$ , just google "cheap java hosting" and you'll find some for 4$.