Updated 20. Marts 2007
The PHP / Java Bridge makes it possible to run use java objects within your PHP code. For example; let’s say you have a jar-file containing some functionality you may want to use in a PHP application.
To use this you must have a Java installed – either the latest version of Java (JDK) or a black hawk version installed.
Get the source code php-java-bridge_3.0.4.tar.bz2 from the PHP / Java bridge website and unpack it with
wget http://switch.dl.sourceforge.net/sourceforge/php-java-bridge/php-java-bridge_3.0.8.tar.bz2
tar xvjf php-java-bridge_3.0.4.tar.bz2
cd php-java-bridge-3.0.4
phpize - in order to use this you'll need to have the php5-dev package installed
./configure --with-java=/usr/lib/j2sdk1.5-sun - be sure to set this to the path where the Java installation is located
If the ./configure command fails because the automake version is less than 1.6 try this
apt-get install automake1.6
update-alternatives --config automake
Select version 1.6 of automake in the update-alternatives dialog and then try to run ./configure again
Now we just need to compile and install, this is done by:
make
make install-modules
Add this line to php.ini in order to enabled the PHP/Java bridge extension:
extension=java.so

Hola.. necesito ayuda me da el error : Call to undefined function java_require(), stoy intentado hacer lo q dice d editar el java.ini pero alli no encuentro ninguna linea java_home, estoy usando php-java-bridge 5.4.4.2.. quien m pueda ayudar c lo agradeceria…!!
Hi.
I’ve got all working just by starting the “mini-server”:
java -jar JavaBridge.jar SERVLET_LOCAL:8080
and running such PHP-script from console:
So, I have a question – why do I need java.so? Because all work fine without this extension.
Hello, thx for the howto.
I install the following this instructions but show me this error.
http://172.17.0.12/java.php
Fatal error: Class ‘Java’ not found in /var/www/java.php on line 4
############################################
java.php
getProperty(’java.version’) . ”;
echo ‘Java vendor=’ . $system->getProperty(’java.vendor’) . ”;
echo ‘OS=’ . $system->getProperty(’os.name’) . ‘ ‘ .
$system->getProperty(’os.version’) . ‘ on ‘ .
$system->getProperty(’os.arch’) . ‘ ‘;
// java.util.Date example
$formatter = new Java(’java.text.SimpleDateFormat’,
“EEEE, MMMM dd, yyyy ‘at’ h:mm:ss a zzzz”);
echo $formatter->format(new Java(’java.util.Date’));
?>
############################################3
Apache log.
[Fri Jul 24 18:24:58 2009] [notice] caught SIGWINCH, shutting down gracefully
Jul 24 18:25:09 VMBridge INFO : VM : 1.6.0_14@http://java.sun.com/
Jul 24 18:25:09 VMBridge INFO : VMBridge version : 5.2.0
Jul 24 18:25:09 VMBridge INFO : logFile :
Jul 24 18:25:09 VMBridge INFO : default logLevel : 3
Jul 24 18:25:09 VMBridge INFO : socket : INET_LOCAL:9267
Jul 24 18:25:09 VMBridge INFO : java.ext.dirs : /usr/lib/jvm/java-6-sun-1.6.0.14/jre/lib/ext:/usr/java/packages/lib/ext
Jul 24 18:25:09 VMBridge INFO : php.java.bridge.base: /usr/lib/php5/20060613+lfs
Jul 24 18:25:09 VMBridge INFO : thread pool size : 20
[Fri Jul 24 18:25:09 2009] [notice] Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch configured — resuming normal operations
Thanks a lot for these instructions! They were really helpful.
The only problem I faced was enabling the PHP/Java bridge extension: In the end, I created a java.ini file in (on my machine) the /etc/php5/conf.d directory and added the following lines:
extension=java.so
[java]
After restarting my apache, it worked.
See also
http://php-java-bridge.sourceforge.net/pjb/installation.php
i have installed tomcat bridge of apachefriends in xampp1.6a ,i want to know what should i do next
Thanks!
Hey mbert
Thats just wonderful when everything just works
Hello Clement
Remember that it requires automake version 1.6
Best regards
Hi !
I want to say you that PHP-Java-Bridge seems can’t be compilde on Debian…
Regards.