LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices



Reply
 
Search this Thread
Old 06-15-2004, 05:27 AM   #1
antony_csf
Member
 
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
|
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);
}

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

Rep: Reputation: 136Reputation: 136
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
 
  


Reply


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


All times are GMT -5. The time now is 03:06 AM.

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