Help php compile javac or java system environment variable
can anyone tell me how to set the environment variable on linux so that it can just run the java or javac command only!!
============================= /usr/java/j2sdk1.4.2_04/bin/java HelloWorld | V java HelloWorld ============================= I have append the line at /etc/profile #set java environment export PATH=$PATH:/usr/java/j2sdk1.4.2_04/bin export JAVA_HOME=/usr/java/j2sdk1.4.2_04 export CLASSPATH=/usr/java/j2sdk1.4.2_04/lib:$CLASSPATH:. the following code works but I don't understand need to specify the whole path to run java and javac at php $last = exec("/usr/java/j2sdk1.4.2_04/bin/javac $filename", $output); $last = exec("/usr/java/j2sdk1.4.2_04/bin/java HelloWorld",$output); <?php if(!defined('_DEBUG_')) define('_DEBUG_',1); if(_DEBUG_) { header('Content-type: text/plain'); ini_set('display_errors','1'); error_reporting(E_ALL); } $filename = "HelloWorld.java"; $last = exec("/usr/java/j2sdk1.4.2_04/bin/javac $filename", $output); if(_DEBUG_) { echo $last."\n"; print_r($output); } $last = exec("/usr/java/j2sdk1.4.2_04/bin/java HelloWorld",$output); if(_DEBUG_) { echo $last."\n"; print_r($output); } ?> |
the PATH depends on which user start httpd ie :
add export PATH=$PATH:/usr/java/j2sdk1.4.2_04/bin to your ~/.bashrc create a infos.php file, put in it : <?php phpinfo(); ?>, place the file in your site directory sudo /sbin/apachectl start With a web browser go to www.yoursite.com/infos.php and look at the PATH indication, it should have /usr/java/j2sdk1.4.2_04/bin in it |
All times are GMT -5. The time now is 11:48 AM. |