Menu

[r456]: / trunk / php-java-bridge / tests.php5 / java_require.php  Maximize  Restore  History

Download this file

43 lines (36 with data), 900 Bytes

 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
#!/usr/bin/php
<?php
if (!extension_loaded('java')) {
if (!(include_once("java/Java.php"))&&!(PHP_SHLIB_SUFFIX=="so" && dl('java.so'))&&!(PHP_SHLIB_SUFFIX=="dll" && dl('php_java.dll'))) {
echo "java extension not installed.";
exit(2);
}
}
$here=realpath(dirname($_SERVER["SCRIPT_FILENAME"]));
if(!$here) $here=getcwd();
//$s = new java("java.lang.String", "hello");
try {
java_require("$here/cachex.jar");
echo "test failed\n";
exit(1);
} catch (JavaException $ex) {
$IOException = new JavaClass("java.io.IOException");
$cause = $ex->getCause();
if(!java_instanceof($cause, $IOException)) {
echo "test failed\n";
exit(3);
}
} catch (Exception $e) {
echo "test failed: $e\n";
exit(2);
}
try {
java_require("$here/cache.jar");
} catch (Exception $ex) {
echo "test failed\n";
exit(4);
}
$Cache = new JavaClass("Cache");
echo "test okay\n";
exit(0);
?>