summaryrefslogtreecommitdiff
path: root/ext/java/README
blob: 1bc43600e4896ab045ec02edf782179ae7232dba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
What is PHP4 ext/java?

   PHP4 ext/java provides a simple and effective means for creating and
   invoking methods on Java objects from PHP.  The JVM is created using JNI,
   and everthing runs in-process.

   Two examples are provided, jver and jawt, to illustrate usage of this
   extension.  A few things to note:

     1) new Java() will create an instance of a class if a suitable constructor
        is available.  If no parameters are passed and the default constructor
        is private, then an instance of the class is returned instead.  This
        is useful as it provides access to classes like "java.lang.system"
        which expose most of their functionallity through static methods.

     2) Accessing a member of an instance will first look for bean properties
        then public fields.  In other words, "print $date.time" will first
        attempt to be resolved as "$date.getTime()", then as "$date.time";

     3) Both static and instance members can be accessed on an object with
        the same syntax.  Furthermore, if the java object is of type
        "java.lang.Class", then static members

     4) Exceptions raised result in PHP warnings, and null results.

     5) Overload resolution is in general a hard problem given the
        differences in types between the two languages.  This being said,
        the current support is pretty lame and I intend to improve it.
        The current algorithm is to pick the first method with the right
        name (ignoring case!) and number of parameters - I warned you it
        was lame!

Build and execution instructions:

   Given the number of platforms and providers of JVMs, no single set of
   instructions will be able to cover all cases.  So in place of hard and
   fast instructions, below are a working examples for a number of free and
   commercial implementations and platforms.  Please adjust the paths to
   suit your installation.  Also, if you happen to get this to work on
   another JVM/platform combination, please let me know, particularly if
   a unique build or execution setup was required.

   This function has been tested in both CGI and Apache (apxs) modes.  As
   the current design requires shared libraries, this support can not be
   linked statically into Apache.

   Finally, it is worth noting that no JVMs are created until the first
   Java call is made.  This not only eliminates unnecessary overhead if
   the extension is never used, it also provides error messages directly
   back to the user instead of being burried in a log some place.
   Additionally, on Unix, the loading of the shared library which implements
   the JVM is also deferred until first use.

========================================================================
===   JVM=Kaffe 1.0.4 (as delivered with OS), OS=Redhat Linux 6.1    ===
========================================================================

build instructions:

   ./configure --with-java

php.ini:

   [java]
   java.library=/usr/lib/kaffe/libkaffevm.so
   java.library.path=/usr/lib/kaffe:/home/rubys/php4/modules
   java.class.path=/usr/share/kaffe/Klasses.jar:/home/rubys/php4/modules/php_java.jar
   extension_dir=/home/rubys/php4/modules
   extension=libphp_java.so

========================================================================
===     JVM=Kaffe 1.0.5 (built from source), OS=Redhat Linux 6.1     ===
========================================================================

build instructions:

   ./configure --with-java

php.ini:

   [java]
   java.library=/usr/local/lib/libkaffevm.so
   java.library.path=/usr/local/lib/kaffe:/home/rubys/php4/modules
   java.class.path=/usr/local/share/kaffe/Klasses.jar:/home/rubys/php4/modules/php_java.jar
   extension_dir=/home/rubys/php4/modules
   extension=libphp_java.so

========================================================================
===                JVM=IBM 1.1.8, OS=Redhat Linux 6.1                ===
========================================================================

build instructions:

   ./configure --with-java=/home/jdk118

php.ini:

   [java]
   java.library=/home/jdk118/lib/linux/native_threads/libjava.so
   java.class.path=/home/jdk118/lib/classes.zip:/home/rubys/php4/modules/php_java.jar
   extension_dir=/home/rubys/php4/modules
   extension=libphp_java.so

========================================================================
===     JVM=Sun/Blackdown 1.2pre-release-v2, OS=Linux (glibc 2.1)    ===
========================================================================

build instructions:

   ./configure --with-java=/usr/local/lib/jdk1.2

php.ini:

   [java]
   java.library=/usr/local/lib/jdk1.2/jre/lib/i386/libjava.so
   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
   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
   extension_dir=/var/tmp/work/php4/modules
   extension=libphp_java.so

You may also have to adapt your LD_LIBRARY_PATH environment variable,
if you didn't add the jdk library paths to /etc/ld.so.conf :

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"

========================================================================
===                JVM=Sun JDK 1.1.8, OS=Windows NT 4                ===
========================================================================

build instructions:

   SET JAVA_HOME=D:\jdk1.1.8
   msdev ext\java\java.dsp /MAKE "java - Win32 Debug_TS"

php.ini:

   [java]
   java.class.path="D:\jdk1.1.8\lib\classes.zip;F:\PHP4\Debug_TS\php_java.jar"
   extension=php_java.dll

========================================================================
===                JVM=Sun JDK 1.2.2, OS=Windows NT 4                ===
========================================================================

build instructions:

   SET JAVA_HOME=D:\jdk1.2.2
   msdev ext\java\java.dsp /MAKE "java - Win32 Debug_TS"

php.ini:

   [java]
   java.class.path=F:\PHP4\Debug_TS\php_java.jar
   extension=php_java.dll