Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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, 05: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, 02:12 PM   #2
LQ Guru
Registered: Mar 2004
Distribution: Slackware
Posts: 5,393

Rep: Reputation: 409Reputation: 409Reputation: 409Reputation: 409Reputation: 409
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 04:04 AM
How to make javac (java compiler) available on whole system? tisam Linux - Software 11 02-14-2005 10:11 AM
use gcc or javac for java compile? jordanGSU Programming 22 10-15-2004 10:12 AM
Help php exec, system function for compile javac or java antony_csf Programming 0 06-15-2004 02:45 AM
Can't compile Java Swing Applet with javac chansky Programming 4 09-23-2002 05:50 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:05 PM.

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