Java, PHP, Programming

Building Web Applications Using PHP and Java

The PHP/Java bridge allows you to quickly access Java classes from within your PHP classes without having to know Java and vice versa. Because of this two-way flexibility, you can access hundreds of pre-built Java classes from PHP, and hundreds of pre-built PHP classes from Java opening up your applications to greater flexibility and enhanced functionality.

Zend Platform Java Bridge is the commercial alternative to PHP/Java Bridge.

Zend Platform Java Bridge

Zend Platform Java Bridge is the leading performance and reliability solution for businesses that seek to utilize both PHP and Java/J2EE.

Based on a unique design that allows for a single Java Virtual Machine (JVM) instantiation and direct calls from PHP, the Java Bridge delivers unprecedented performance and scalability that make true PHP and Java integration a reality.

Java Bridge code can be run and debugged in the same way as normal PHP code.

Java Bridge Functionality

Java Bridge provides four main functions:

1. Function invocation

Java Bridge provides code completion for the following Java functions/methods:

  • java_get_statistics() – Get Java server statistics
  • java_get_version_info() – Get Java extension version information
  • java_last_exception_clear() – Clear last Java exception
  • java_last_exception_get() – Get last Java exception
  • java_set_encoding() – Set encoding for PHP-Java data transfers
  • java_set_ignore_case() – Set if search for Java classes and methods should be case-insensitive
  • java_throw_exceptions() – Set if exceptions should be thrown on errors

2. Java instantiation: Creates new Java-PHP Objects

Zend Studio for Eclipse supports Java Object instances. After instantiation of a PHP Java object, the PHP variable it was assigned to assumes the properties and methods of the Java class. This allows the object to implement Java functionality, as well as allowing access to Java’s Code Assist options.

Assignments attach the resulting Java object to the PHP variable.

 * Java Bridge instantiation
$firstService = new java("com.zend.FirstService");
$secondService = new java("com.zend.SecondService");

3. Java Exception handling: Catching Java exceptions

Java exceptions can be caught by Zend Studio for Eclipse using Java Bridge.

 * Java exception handling
try {
	$a = new java("");
	// java invocations
} catch (JavaException $e) {
	print "problem with java execution...";
	print $e->getCause();

4. Automatic Type Conversion

The Java Bridge will also perform the following conversions to PHP objects when Java objects are returned:


8 thoughts on “Building Web Applications Using PHP and Java

  1. Pingback: To take away
  2. Pingback: To take away
  3. hey, thanks for the info. also, do you know how i can call a php function from a java application? a working example would help a lot. thanks much!

  4. Thanks for the information. Please examples of using PHP/Java Bridge and what need to be done for this two application to work properly will be of more help.

    once again well done.

  5. hi,

    thanks for such a great article.
    solved my jsp to php project migration problem


  6. hi! i am sujoy ..i want to know that—-i have implemented a web application in j2ee(chat application) and my friend has implemented a web page ,,my query is that can i make a project using both of them in a same platform through bridging???plss reply

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s