How to use the PHP/Java Bridge in Eclipse.
This guide shows how to develop PHP/Java applications using an eclipse-based PHP IDE.
Install Eclipse and the PHP/Java Bridge library
- Download and install an eclipse-based PHP IDE, for example Zend Studio.
- Create a PHP project and drag and drop Java.inc and JavaBridge.jar to your eclipse PHP project using a file manager.
Test your eclipse project
- Create a PHP test script. For example:
<?php
define("JAVA_SERVLET", false); define("JAVA_HOSTS", 9267); require_once("Java.inc");
echo new java("java.lang.String", "hello world");
echo java("java.lang.System")->getProperties();
?>
- Run your test script. Click on the run button and wait up to 30 seconds for the first result to appear.
- Your PHP script has started a Java server in the background and called the Java procedure "java.lang.System.getProperties()".
- Develop your PHP/Java application. Use the procedure
echo java_inspect($jval)to inspect a Java class from PHP. Either use the procedurejava_require("app.jar;lib1.jar;libn.jar")to load Java applications and their libraries dynamically or change theJAVA_SERVLETandJAVA_HOSTSto use a Java application back end.