Menu

[r619]: / trunk / php-java-bridge / INSTALL.STANDALONE  Maximize  Restore  History

Download this file

81 lines (50 with data), 2.1 kB

Overview
--------

This document describes how to call a non-J2EE application. Please see
the INSTALL.J2SE document for details how to call PHP methods from
Java. Please see the INSTALL.J2EE document for details how to embed
PHP into a pure J2EE application server or how to call Java/J2EE
methods from PHP.

Development
-----------

* Right-click on log4j.jar and select "open with Java ..."

* Right-click on JavaBridge.jar and select "open with Java ...". In
  the "Starting ..." dialog select SERVLET_LOCAL:8080.

* Run your PHP scripts. For example browse to http://127.0.0.1:8080
  and click on test.php.


Deployment
----------

* Extract the JavaBridge.jar library from JavaBridge.war, for example
  with the command:

   java -classpath JavaBridge.war TestInstallation
   
* Add the following 3 lines to the main class of your non-J2EE
application:

     public static final String JAVABRIDGE_PORT="8087";
     static final php.java.bridge.JavaBridgeRunner runner = 
       php.java.bridge.JavaBridgeRunner.getRequiredInstance(JAVABRIDGE_PORT);
     
* Add JavaBridge.jar to the main library of you non-J2EE
application. This can be done by adding the following line to your
application's META-INF/MANIFEST.MF:
  
    Class-Path: JavaBridge.jar

It is also possible to simply merge all files into your non-J2EE
application..
  
* Start your non-J2EE application.


Call your Java methods from PHP
-------------------------------

* Use the following code to call methods:

    <?php require_once("http://localhost:8087/JavaBridge/java/Java.inc");

    $myClass = new java("com.my.non.j2ee.application.MyClass");
    $myClass->myMethod(...);
    ?>


Logging
-------

* Download and copy log4j.jar to java.ext.dirs. Example for JDK 1.6 on
  Linux:

  mkdir -p /usr/java/packages/lib/ext
  cp log4j.jar /usr/java/packages/lib/ext

* Start the log4j viewer. For example with the command:

  /usr/java/default/bin/java org.apache.log4j.chainsaw.Main

* Restart the standalone application. The log appears in the log4j
  window.


* Please report bugs/problems to the mailing list:

    php-java-bridge-users@lists.sourceforge.net
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.