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.

154 lines
6.1 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 private, then an instance of the class is returned instead. This
  10. is useful as it provides access to classes like "java.lang.system"
  11. which expose most of their functionallity through static methods.
  12. 2) Accessing a member of an instance will first look for bean properties
  13. then public fields. In other words, "print $date.time" will first
  14. attempt to be resolved as "$date.getTime()", then as "$date.time";
  15. 3) Both static and instance members can be accessed on an object with
  16. the same syntax. Furthermore, if the java object is of type
  17. "java.lang.Class", then static members
  18. 4) Exceptions raised result in PHP warnings, and null results.
  19. 5) Overload resolution is in general a hard problem given the
  20. differences in types between the two languages. This being said,
  21. the current support is pretty lame and I intend to improve it.
  22. The current algorithm is to pick the first method with the right
  23. name (ignoring case!) and number of parameters - I warned you it
  24. was lame!
  25. Build and execution instructions:
  26. Given the number of platforms and providers of JVMs, no single set of
  27. instructions will be able to cover all cases. So in place of hard and
  28. fast instructions, below are a working examples for a number of free and
  29. commercial implementations and platforms. Please adjust the paths to
  30. suit your installation. Also, if you happen to get this to work on
  31. another JVM/platform combination, please let me know, particularly if
  32. a unique build or execution setup was required.
  33. This function has been tested in both CGI and Apache (apxs) modes. As
  34. the current design requires shared libraries, this support can not be
  35. linked statically into Apache.
  36. Finally, it is worth noting that no JVMs are created until the first
  37. Java call is made. This not only eliminates unnecessary overhead if
  38. the extension is never used, it also provides error messages directly
  39. back to the user instead of being burried in a log some place.
  40. Additionally, on Unix, the loading of the shared library which implements
  41. the JVM is also deferred until first use.
  42. ========================================================================
  43. === JVM=Kaffe 1.0.4 (as delivered with OS), OS=Redhat Linux 6.1 ===
  44. ========================================================================
  45. build instructions:
  46. ./configure --with-java
  47. php.ini:
  48. [java]
  49. java.library=/usr/lib/kaffe/libkaffevm.so
  50. java.library.path=/usr/lib/kaffe:/home/rubys/php4/modules
  51. java.class.path=/usr/share/kaffe/Klasses.jar:/home/rubys/php4/modules/php_java.jar
  52. extension_dir=/home/rubys/php4/modules
  53. extension=libphp_java.so
  54. ========================================================================
  55. === JVM=Kaffe 1.0.5 (built from source), OS=Redhat Linux 6.1 ===
  56. ========================================================================
  57. build instructions:
  58. ./configure --with-java
  59. php.ini:
  60. [java]
  61. java.library=/usr/local/lib/libkaffevm.so
  62. java.library.path=/usr/local/lib/kaffe:/home/rubys/php4/modules
  63. java.class.path=/usr/local/share/kaffe/Klasses.jar:/home/rubys/php4/modules/php_java.jar
  64. extension_dir=/home/rubys/php4/modules
  65. extension=libphp_java.so
  66. ========================================================================
  67. === JVM=IBM 1.1.8, OS=Redhat Linux 6.1 ===
  68. ========================================================================
  69. build instructions:
  70. ./configure --with-java=/home/jdk118
  71. php.ini:
  72. [java]
  73. java.library=/home/jdk118/lib/linux/native_threads/libjava.so
  74. java.class.path=/home/jdk118/lib/classes.zip:/home/rubys/php4/modules/php_java.jar
  75. extension_dir=/home/rubys/php4/modules
  76. extension=libphp_java.so
  77. ========================================================================
  78. === JVM=Sun/Blackdown 1.2pre-release-v2, OS=Linux (glibc 2.1) ===
  79. ========================================================================
  80. build instructions:
  81. ./configure --with-java=/usr/local/lib/jdk1.2
  82. php.ini:
  83. [java]
  84. java.library=/usr/local/lib/jdk1.2/jre/lib/i386/libjava.so
  85. java.library.path=/usr/local/lib/jdk1.2/jre/lib/i386/classic:/usr/local/lib/jdk1.2/jre/lib/i386/native_threads:/usr/local/lib/jdk1.2/jre/lib/i386:/var/tmp/work/php4/modules
  86. java.class.path=/usr/local/lib/jdk1.2/jre/lib/rt.jar:/usr/local/lib/jdk1.2/jre/lib/i18n.jar:/var/tmp/work/php4/modules/php_java.jar
  87. extension_dir=/var/tmp/work/php4/modules
  88. extension=libphp_java.so
  89. You may also have to adapt your LD_LIBRARY_PATH environment variable,
  90. if you didn't add the jdk library paths to /etc/ld.so.conf :
  91. LD_LIBRARY_PATH="/usr/local/lib/jdk1.2/jre/lib/i386:/usr/local/lib/jdk1.2/jre/lib/i386/classic:/usr/local/lib/jdk1.2/jre/lib/i386/native_threads:$LD_LIBRARY_PATH"
  92. ========================================================================
  93. === JVM=Sun JDK 1.1.8, OS=Windows NT 4 ===
  94. ========================================================================
  95. build instructions:
  96. SET JAVA_HOME=D:\jdk1.1.8
  97. msdev ext\java\java.dsp /MAKE "java - Win32 Debug_TS"
  98. php.ini:
  99. [java]
  100. java.class.path="D:\jdk1.1.8\lib\classes.zip;F:\PHP4\Debug_TS\php_java.jar"
  101. extension=php_java.dll
  102. ========================================================================
  103. === JVM=Sun JDK 1.2.2, OS=Windows NT 4 ===
  104. ========================================================================
  105. build instructions:
  106. SET JAVA_HOME=D:\jdk1.2.2
  107. msdev ext\java\java.dsp /MAKE "java - Win32 Debug_TS"
  108. php.ini:
  109. [java]
  110. java.class.path=F:\PHP4\Debug_TS\php_java.jar
  111. extension=php_java.dll