Menu

[r105]: / trunk / php-java-bridge / tests.php5 / printStackTrace.php  Maximize  Restore  History

Download this file

23 lines (19 with data), 482 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/php
<?php
if(!extension_loaded('java')) {
dl('java.' . PHP_SHLIB_SUFFIX);
}
try {
try {
new java("java.lang.String", null);
} catch(java_exception $ex) {
// print the stack trace to $trace
$trace = new java("java.io.ByteArrayOutputStream");
$ex->printStackTrace(new java("java.io.PrintStream", $trace));
echo "Exception occured:" . $trace . "\n";
return 0;
}
} catch (exception $err) {
print "An error occured: $err\n";
return 1;
}