Thorazine 10mg Online
  • 22nd November 2007 - By Vinu Thomas

    If you’re looking for the easiest way to install the PHP Java Bridge in Ubuntu, follow these simple steps:

    If you don’t have Java Installed on your machine, enable the multiverse option in your Software Sources and run

    sudo apt-get install sun-java6-jre sun-java6-fonts sun-java6-jdk sun-java6-plugin
    sudo update-java-alternatives -s java-6-sun

    Download the PHP Java bridge deb files from Sourceforge.

    Head over to the directory where you’ve downloaded this deb file, and fire the following commands:

    sudo apt-get install liblucene-java libitext-java
    sudo dpkg -i php-java-bridge_4.3.0-1_i386.deb

    Once the php-java-bridge deb file is installed, apache will be automatically restarted. If apache doesn’t restart automatically, you can restart apache with the following command:

    sudo /etc/init.d/apache2 restart

    How do you check if the PHP Java bridge is installed?
    Run the phpinfo() command in php. This should give you the details of the PHP Java bridge extension under the Java Heading. Now you’re ready to run Java code in PHP :)

    Now head over to the following link and check out the second part of the tutorial to get started on PHP and Java.

    More on the PHP Java bridge over at:


    Here’s another Article which shows how to bridge PHP an Java in Windows using Apache Tomcat:

  • 29 Comments to “Installing the PHP Java Bridge in Ubuntu (Gutsy Gibbon)”

    • vinu on November 22, 2007

      These instructions should work on Fiesty Fawn too.

    • [...] his blog, Vinu Thomas has posted a guide to installing the Java bridge for PHP on an Ubuntu system: If you’re looking for the [...]

    • [...] in November 23rd, 2007 by admin in Java, PHP, Programming, Tutorials On his blog, Vinu Thomas has posted a guide to installing the Java bridge for PHP on an Ubuntu system. The basic steps are quick and easy – be [...]

    • [...]  Installing the PHP Java Bridge in Ubuntu (Gutsy Gibbon) (0 visite) [...]

    • joomla on November 30, 2007

      Thx for tip!

    • Nicolas Dezorthes on December 4, 2007

      No working for me, i’v got this error on install :
      php-java-bridge depend of libc6 (>= 2.3.6-6) but the version of libc6 on the systeme is 2.3.6-0ubuntu20.5.
      No version of libc6 more recent seems available, ay idea to fix this problem?

    • vinu on December 5, 2007

      The newer versions of Ubuntu ship with libc6 of the required version. Which version of Ubuntu are you currently running?

    • Nicolas Dezorthes on December 7, 2007

      I’am on Ubuntu Dapper.

    • Charles Shaffer on June 4, 2008

      I installed the Java Bridge per instructions and it seemed to go fine, but when I run a test I get this error.

      Fatal error: Class ‘java’ not found in /var/www/cs_dev/validate_part.php on line 8

      $U2 = new java(‘com.ntnbower.t4mutil’);

      The U2 object in the com.ntnbower.t4mutil package ahs been tested and works fine when called from another java class (with main).

      Does PHP need to be recompiled with the with-java directive? Or does the bridge make that unnecessary.

    • vinu on June 4, 2008

      Are you using the PHP which came along with the Ubuntu repositories or did you manually compile PHP?
      If you used the Ubuntu repositories and followed the steps above it should work as is without having to recompile PHP.
      Just get your phpinfo() and see if you see Java listed in the list of extensions.

    • Charles Shaffer on June 4, 2008


      Yes. We are using the PHP that came with the Ubuntu install. PHPINFO says Java Support is enabled and the status is running. But java_home says no value. I wonder if the problem is with the java install. The error says the class Java is not found. I downloaded the latest Java from Sun as a self-extracting file. Was that unnecessary?

    • Charles Shaffer on June 4, 2008

      OK. Downloading the self-extracting java was a mistake. Our Linux guy helped me get rid of the self-extracting version of Java and we reinstalled the apt-get versions of java and the java bridge. PHP is aware of java and the status is running. It still doesn’t find the java class though. I just have a feeling this is an environment issue (PATH, CLASSPATH, ?) but I don’t know what the problem is. Do you need to import java somehow?

    • vinu on June 4, 2008

      I missed out one more point to ask. Did you set the path to the class files in your php code ? You can do that by using:

      $U2 = new java(’com.ntnbower.t4mutil’);

    • Charles Shaffer on June 4, 2008

      By the way, if it matters we are using Feisty Fawn.

    • Charles Shaffer on June 5, 2008


      Progress. Sort of. When I add the require_java() statement the java object seems to be created OK, but there is an error further on.

      With this code:
      $U2 = new java(‘U2′);
      $result = $U2->IsValidPartNumber($partnumber);
      if($result) print “Found”; (line 13)
      else print “Not Found”;

      This error:
      Parse error: syntax error, unexpected T_STRING in /var/www/cs_dev/validate_part.php on line 13

      With the require_java line commented out the error occurs when creating the new U2 object, which makes sense.

      Do you see why the require_java call is causing the T_STRING error?


    • Charles Shaffer on June 5, 2008

      More progress sort of.

      I discovered that by changing the quotes in the require_java statement

      I got rid of the parser errors.

      At run time I got
      Fatal error: Call to undefined function java_require() in /var/www/cs_dev/validate_part.php on line 9

      Do I need to set a path to somewhere?

    • vinu on June 6, 2008

      Ok. Here’s my guess Charles – This line may be the cause:
      $result = $U2->IsValidPartNumber($partnumber);
      If the parameter is defined as integer in Java, PHP is unable to send $partnumber to Java, since it’s taken as a string.
      $result = $U2->IsValidPartNumber($partnumber+0);
      Which will implicitly change the datatype to integer. Leave the java_require with the double quotes:

      “This bridge does not convert data dynamically like the core PHP engine does. You must do type conversion in your PHP code.”
      More information on this over at:

    • Charles Shaffer on June 10, 2008

      Hello vinu,

      I got side tracked for a while, but I’m back on the PHP-Java Bridge now. I have created a jar file called U2web.jar and put it in /usr/lib/jclass/ directory. /usr/lib/jclass/U2web.jar is in the CLASSPATH. In a standard java program I import import com.ntnbower.t4mutil.*; and this works fine.

      In the php code I include
      java_require(‘/usr/lib/jclass/U2web.jar’); When I create the new object I use
      $U2 = new Java(‘com.ntnbower.t4mutil.U2′);

      It fails on test and I get this error
      Unresolved external reference: java.lang.NoClassDefFoundError: asjava/uniobjects/UniSessionException. — Unable to call constructor, see the README section “Java platform issues” for details

      Do you know where I could find the README this refers to?

    • vinu on June 10, 2008

      Hi Charles,
      Change your Java require line to :
      It just needs the path to the class file. The jar file should not be specified in the the java_require line.

    • Charles Shaffer on June 11, 2008


      Sorry for all of the questions.

      After changing the java_require to

      get this error
      CreateInstance failed: new com.ntnbower.t4mutil.U2. Cause: java.lang.ClassNotFoundException: Could not find com.ntnbower.t4mutil.U2 in java_require() path. Please check the path and the SEL and File permissions

      The class is in a jar file called U2web.jar jar tvf U2web.jar
      0 Tue Jun 10 13:10:58 CDT 2008 META-INF/
      71 Tue Jun 10 13:10:58 CDT 2008 META-INF/MANIFEST.MF
      1931 Tue Jun 10 13:10:22 CDT 2008 com/ntnbower/t4mutil/U2.class

      Permissions on the jclas directory are 755

      Don’t know what SEL is referring to.

      PHP code
      print “Hello”;

      Just trying to get past the instantiation at this point.

    • Charles Shaffer on June 11, 2008


      Well I think it is working now. I had to put a reference in the java_require to a class that is imported in the class I developed.


      Thanks for all of your help.

    • vinu on July 14, 2008

      Here’s another Article which shows how to bridge PHP an Java in Windows using Apache Tomcat:

    • Slei on August 14, 2008

      I installed the php-java-bridge , but still having this error:
      Fatal error: Class ‘Java’ not found

      I didn’t install PHP5 from .deb package, I compiled the source to install PHP5 and Apache2.

      What I have to do? do I have to recompile PHP5 with Java, but when I run ./configure –help there is no –with-java option in PHP5….

      Thanks for your help.

    • vinu on August 19, 2008

      It looks like PHP cannot find Java. Since you’ve used custom compiled versions of PHP, the installer may not have updated your PHP.ini.
      The following link may be useful for you:

    • dbigand on October 5, 2008


      Just and require_once(‘’); in you’re script.

      You’ll find this file in the source directory of php_java_bridge.



    • Hakan on December 17, 2008

      That did the trick for me. Thanks!

    • Jaime on May 13, 2010

      I am having trouble installing PHP Java Bridge on Ubuntu 9.04 64 bit I have Tomcat 6 and Apache2 installed and have not been able to does anyone have any other ideas as to what is the best way to achieve this?

    • Mihiri on February 23, 2012

      error processing php-java-bridge_4.3.0-1_i386.deb (–install):
      package architecture (i386) does not match system (amd64)

      how can i solve this?

    • Vinu Thomas on March 1, 2012

      The downloads for the debian version gives you only the 32 bit version of the installer. This won’t work on a 64bit OS installation.

    Leave a Reply