Menu

[r557]: / trunk / php-java-bridge / test.php  Maximize  Restore  History

Download this file

90 lines (78 with data), 3.0 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/env php
<?php
/**
* require_once("http://localhost:8080/JavaBridge/java/Java.inc");
* $System = new Java("java.lang.System");
* phpinfo();
* echo $System->getProperties();
*/
/*
* Don't try to understand the code below ...
*/
/* load extension and check it */
function check_extension() {
if(!extension_loaded('java')) {
$sapi_type = php_sapi_name();
$port= (isset($_SERVER['SERVER_PORT']) && (($_SERVER['SERVER_PORT'])>1024)) ? $_SERVER['SERVER_PORT'] : '8080';
if ($sapi_type == "cgi" || $sapi_type == "cgi-fcgi" || $sapi_type == "cli") {
if(!(PHP_SHLIB_SUFFIX=="so" && @dl('java.so'))&&!(PHP_SHLIB_SUFFIX=="dll" && @dl('php_java.dll'))&&!(@include_once("java/Java.inc"))&&!(require_once("http://127.0.0.1:$port/JavaBridge/java/Java.inc"))) {
echo "java extension not installed.";
exit(2);
}
} else {
if(!(@include_once("java/Java.inc")))
require_once("http://127.0.0.1:$port/JavaBridge/java/Java.inc");
}
}
if(!function_exists("java_get_server_name")) {
echo "Fatal: The loaded java extension is not the PHP/Java Bridge";
exit(7);
}
}
check_extension();
if(java_get_server_name()!=null){
phpinfo();
print "\n\n";
$v = new JavaClass("java.lang.System");
$p = @$v->getProperties();
if($ex=java_last_exception_get()) {
$trace = new Java("java.io.ByteArrayOutputStream");
$ex->printStackTrace(new java("java.io.PrintStream", $trace));
echo "Exception $ex occured:<br>\n" . $trace . "\n";
exit(1);
}
$arr=java_values($p);
foreach ($arr as $key => $value) {
print $key . " -> " . $value . "<br>\n";
}
echo "<br>\n";
$Util = new JavaClass("php.java.bridge.Util");
echo "JavaBridge back-end version: ".java_values($Util->VERSION)."<br>\n";
echo "<br>\n";
} else {
phpinfo();
print "\n\n";
/* java_get_server_name() == null means that the back-end is not
running */
if(PHP_SHLIB_SUFFIX=="so") $ext_name="java.so";
else if(PHP_SHLIB_SUFFIX=="dll") $ext_name="php_java.dll";
else $ext_name="unknown suffix: ".PHP_SHLIB_SUFFIX;
echo "Error: The PHP/Java Bridge back-end is not running.\n";
echo "\n";
echo "Please start it and/or check if the directory\n";
echo "\n\t".ini_get("extension_dir")."\n\n";
echo "contains \"$ext_name\" and \"JavaBridge.jar\".\n";
echo "\n";
echo " Check if the following values are correct:\n\n";
echo "\tjava.java_home = ".ini_get("java.java_home")."\n";
echo "\tjava.java = ".ini_get("java.java")."\n\n";
echo "If you want to start the back-end automatically, disable:\n\n";
echo "\tjava.socketname = ".ini_get("java.socketname")."\n";
echo "\tjava.hosts = ".ini_get("java.hosts")."\n";
echo "\tjava.servlet = ".ini_get("java.servlet")."\n";
echo "\n";
echo "If that still doesn't work, please check the \"java command\" above and\n";
echo "report this problem to:\n\n";
echo "\tphp-java-bridge-users@lists.sourceforge.net.\n";
}
?>
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.