PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
hi,
i am kind of newbie in php. i am trying to run java program from php whithout having to instal php/java bridge on linux
bascally i am using the following commands
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
<?php
//If this is a linux server
exec("export CLASSPATH=:.:/opt/java/lib:/opt/java/jre/lib:/opt/java/lib/tools.jar");
exec("export JAVA_HOME=/opt/java");
//or if this is a windows server
exec("set CLASSPATH=:.: ..... ");
exec("set JAVA_HOME= ..... ");
$r1 = exec("javac hello.java");
$r2 = exec("java hello");
echo $r1;
echo $r2;
?>