tags:

views:

34

answers:

2

I am trying to run a java command like this in a PHP Joomla Component. It works, however, the files generated from the command are written to /administrator and I want them to be written to the location where the Java command resides ie. /administrator/com_mycomponent/java/MyJavaApp.jar

            //run the command
            $javaCommand = "$javaCommand -jar $keyGeneratorFile $appName";
            $response = exec($javaCommand);

            if(empty($response)) {
                JError::raiseError(500, "Key Generation failed for command: $javaCommand");
            }

What can I do? Is there some sort of option I can use with the java command?

A: 

If you can change the java program you can use the solutions discussed in following question:

http://stackoverflow.com/questions/2682194/get-location-from-where-the-java-code-is-executed

Tahir Akhtar
This does not seem to help
jax
Can you share the java code you tried?
Tahir Akhtar
I solved this by changing the java app to take an output directory as a parameter
jax
A: 

You could create a script that first changes to the directory you want and then runs the command. Then call exec on that script.

Will Mavis