Visit the LQ Articles and Editorials section
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 06-15-2004, 04:27 AM   #1
Registered: Jun 2004
Posts: 51

Rep: Reputation: 15
Unhappy 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
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);


if(!defined('_DEBUG_')) define('_DEBUG_',1);

header('Content-type: text/plain');

$filename = "";
$last = exec("/usr/java/j2sdk1.4.2_04/bin/javac $filename", $output);
echo $last."\n";

$last = exec("/usr/java/j2sdk1.4.2_04/bin/java HelloWorld",$output);
echo $last."\n";

Old 06-16-2004, 01:12 PM   #2
Senior Member
Registered: Mar 2004
Distribution: Slackware
Posts: 4,617

Rep: Reputation: 137Reputation: 137
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
and look at the PATH indication, it should have /usr/java/j2sdk1.4.2_04/bin in it


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Java Programming: Java Runtime Environment not found when trying to compile murbz Linux - Software 2 03-26-2009 03:04 AM
How to make javac (java compiler) available on whole system? tisam Linux - Software 11 02-14-2005 09:11 AM
use gcc or javac for java compile? jordanGSU Programming 22 10-15-2004 09:12 AM
Help php exec, system function for compile javac or java antony_csf Programming 0 06-15-2004 01:45 AM
Can't compile Java Swing Applet with javac chansky Programming 4 09-23-2002 04:50 PM

All times are GMT -5. The time now is 12:36 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration