You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

162 lines
6.2 KiB

  1. What is PHP4 ext/java?
  2. PHP4 ext/java provides a simple and effective means for creating and
  3. invoking methods on Java objects from PHP. The JVM is created using JNI,
  4. and everthing runs in-process.
  5. Two examples are provided, jver and jawt, to illustrate usage of this
  6. extension. A few things to note:
  7. 1) new Java() will create an instance of a class if a suitable constructor
  8. is available. If no parameters are passed and the default constructor
  9. is useful as it provides access to classes like "java.lang.System"
  10. which expose most of their functionallity through static methods.
  11. 2) Accessing a member of an instance will first look for bean properties
  12. then public fields. In other words, "print $date.time" will first
  13. attempt to be resolved as "$date.getTime()", then as "$date.time";
  14. 3) Both static and instance members can be accessed on an object with
  15. the same syntax. Furthermore, if the java object is of type
  16. "java.lang.Class", then static members
  17. 4) Exceptions raised result in PHP warnings, and null results.
  18. 5) Overload resolution is in general a hard problem given the
  19. differences in types between the two languages. The PHP Java
  20. extension employs a simple, but fairly effective, metric for
  21. determining which overload is the best match.
  22. Additionally, method names in PHP are not case sensitive, potentially
  23. increasing the number of overloads to select from.
  24. Once a method is selected, the parameters are cooerced if necessary,
  25. possibly with a loss of data (example: double precision floating point
  26. numbers will be converted to boolean).
  27. Build and execution instructions:
  28. Given the number of platforms and providers of JVMs, no single set of
  29. instructions will be able to cover all cases. So in place of hard and
  30. fast instructions, below are a working examples for a number of free and
  31. commercial implementations and platforms. Please adjust the paths to
  32. suit your installation. Also, if you happen to get this to work on
  33. another JVM/platform combination, please let me know, particularly if
  34. a unique build or execution setup was required.
  35. This function has been tested in both CGI and Apache (apxs) modes. As
  36. the current design requires shared libraries, this support can not be
  37. linked statically into Apache.
  38. With ext/java, no Java Virtual Machines are created until the first
  39. Java call is made. This not only eliminates unnecessary overhead if
  40. the extension is never used, it also provides error messages directly
  41. back to the user instead of being burried in a log some place.
  42. For people interested in robustness, performance, and more complete
  43. integration with Java, consider using the sapi/servlet interface which
  44. is built upon the Java extension. Running PHP as a servlet enables PHP
  45. to utilize the existing JVM and threads from the servlet engine, and
  46. provides direct access to the servlet request and response objects.
  47. ========================================================================
  48. === JVM=Kaffe 1.0.4 (as delivered with OS), OS=Redhat Linux 6.1 ===
  49. ========================================================================
  50. build instructions:
  51. ./configure --with-java
  52. php.ini:
  53. [java]
  54. java.library.path=/usr/lib/kaffe:/home/rubys/php4/modules
  55. java.class.path=/usr/share/kaffe/Klasses.jar:/home/rubys/php4/modules/php_java.jar
  56. extension_dir=/home/rubys/php4/modules
  57. extension=libphp_java.so
  58. ========================================================================
  59. === JVM=Kaffe 1.0.5 (built from source), OS=Redhat Linux 6.1 ===
  60. ========================================================================
  61. build instructions:
  62. ./configure --with-java
  63. php.ini:
  64. [java]
  65. java.library.path=/usr/local/lib/kaffe:/home/rubys/php4/modules
  66. java.class.path=/usr/local/share/kaffe/Klasses.jar:/home/rubys/php4/modules/php_java.jar
  67. extension_dir=/home/rubys/php4/modules
  68. extension=libphp_java.so
  69. ========================================================================
  70. === JVM=IBM 1.1.8, OS=Redhat Linux 6.1 ===
  71. ========================================================================
  72. build instructions:
  73. ./configure --with-java
  74. php.ini:
  75. [java]
  76. java.class.path=/home/jdk118/lib/classes.zip:/home/rubys/php4/modules/php_java.jar
  77. extension_dir=/home/rubys/php4/modules
  78. extension=libphp_java.so
  79. ========================================================================
  80. === JVM=Blackdown 1.2.2 RC4, OS=Redhat Linux 6.1 ===
  81. ========================================================================
  82. build instructions:
  83. ./configure --with-java
  84. php.ini:
  85. [java]
  86. java.class.path=/home/rubys/php4/lib/php_java.jar
  87. extension_dir=/home/rubys/php4/modules
  88. extension=libphp_java.so
  89. ========================================================================
  90. === JVM=Sun JDK 1.2.2, OS=Linux ===
  91. ========================================================================
  92. This compiler is not supported at this time. At the moment, only green
  93. threads are supported, requiring system calls to be wrapped, which is
  94. incompatible with the JNI Invocation API. Once native threads are
  95. supported, It is expected that the configuration will be identical to
  96. the Blackdown JDK.
  97. ========================================================================
  98. === JVM=Sun JDK 1.1.8, OS=Windows NT 4 ===
  99. ========================================================================
  100. build instructions:
  101. SET JAVA_HOME=D:\jdk1.1.8
  102. msdev ext\java\java.dsp /MAKE "java - Win32 Debug_TS"
  103. php.ini:
  104. [java]
  105. java.class.path="D:\jdk1.1.8\lib\classes.zip;F:\PHP4\Debug_TS\php_java.jar"
  106. extension=php_java.dll
  107. ========================================================================
  108. === JVM=Sun JDK 1.2.2, OS=Windows NT 4 ===
  109. ========================================================================
  110. build instructions:
  111. SET JAVA_HOME=D:\jdk1.2.2
  112. msdev ext\java\java.dsp /MAKE "java - Win32 Debug_TS"
  113. php.ini:
  114. [java]
  115. java.class.path=F:\PHP4\Debug_TS\php_java.jar
  116. extension=php_java.dll