The Java Bridge is only active when the Java Bridge component is installed and activated. The component's status and settings can be viewed and configured in the UI, on the Configurations | Components page.
Note:
The Java Bridge requires that you have Oracle's JRE 1.5 (or later) or IBM's Java 1.5 (or later) installed on your computer. During (or after) installing (depending on the installation type), you are prompted to direct the installer to the JRE location. You should, therefore, already have JRE installed. More information about JRE and the latest updates can be obtained from www.java.com.
This procedure describes how to install and enable the Java Bridge component depending on the Zend Server installation type.
|
|
Windows
Linux
aptitude install php-5.5-java-bridge-zend-server aptitude install php-5.6-java-bridge-zend-server
Mac OS X
|
This procedure describes how to configure the target Java runtime environment.
|
|
Configuring the runtime environment: Use the following command to run JavaMW: java com.zend.javamw.JavaServer For correct execution, the classpath should include the javamw.jar file in the directory where JavaMW is installed. |
|
|
|
Example: UNIX, Linux, IBM i and Mac <install_dir>/bin/javamw.jar Windows <install_dir>\bin\javamw.jar |
|
The following code sample shows how you can, as an initial step, test the connection between your PHP and Java environments to ensure that the Java Bridge is defined properly and communicates with the correct Java. This code demonstrates the interaction between a PHP application and Java objects that occurs in the Java Bridge implementation.
|
|
To test the Java Bridge connection: Create a new PHP script to create a Java object, as in the example below:
If the Java Bridge is correctly installed and running, you should receive the following response:
This output shows the date, Java version, vendor and operating
system and indicates that the connection is complete.
|
|
Once the connection is established, you can start using the API to call Java objects from your PHP. |
Before you start incorporating the Java Bridge API in your code, you
must be aware that when you call Java from PHP, you must use Java coding
standards to call the correct objects, because the Java Bridge does not
perform dynamic data conversion. You must perform the type conversion
in your PHP code.
For example,
|
Example: If you call a Java method that looks like this: public void doSomething(int i); Using what you would expect to work in PHP: $var = "1" $javaObject->doSomething($var); The Java Bridge throws an exception. To avoid this, use the following line of code to convert the parameter from a string to a numeric value before the Java Bridge passes it: $javaObject->doSomething($var + 0); |
|
For more information, see the API, or Java Bridge Use Cases.
This procedure describes how to configure the Zend Java Bridge component. For more information on working with this component, see Working with Components.
|
|
|
To configure the component:
|
For information on configuring the component daemon directives, see Configuring Component Daemon Directives (Zend Session Clustering, Zend Deployment, Zend Java Bridge, Zend Job Queue, and Zend Monitor). |