[RESOLVED] Detect JRE in server using PHP
Can php detect if webserver has installed JRE or not?
I think i know the answer..
The solution : call program java -version.
This assume that i not install php-java extension.
If the JRE is exists, then it will print the java version.
Otherwise, it will output program not found.
This works in my Ubuntu 7.10
It will output :
$command = "java -version 2>&1";
Why we can not just write it "java -version"?
 => java version "1.6.0_03"
 => Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
 => Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing)
So, how we can catch error messages when calling exec?
Originally Posted by Rob Prime on [url
For full answer, visit : http://id2.php.net/manual/en/function.exec.php#35917
To find the exact version of JRE, just use regex on $output variable.
the only problem is that this approach is dependent on having the java executable on the path of the user executing your PHP script. right now you're running on ubuntu so more likely than not, PHP is running as you. however, in production servers PHP will likely be executed as 'nobody' meaning java has to be on nobody's path.
Originally Posted by chazzy
You are right!! Absolutely right!!
So then, it down again..
You have better approach or technique??
Please help, and thanks for your precious information...
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)