Click to See Complete Forum and Search --> : PHP + ext/java on Linux: not working.


Anon
12-27-2000, 02:41 PM
Hiya.

I need help getting ext/java to work in PHP on Linux. I'm using the blackdown java port, the JDK I downloaded was 1.3FCS. I have it installed in /usr/local/java (that's a symlink to its actual location). I compiled PHP like so:

./configure --with-mysql=/usr --with-java --with-apxs=/usr/local/apache/bin/apxs

after setting JAVA_HOME to /usr/local/java and putting JAVA_HOME/bin in my PATH. PHP compiled successfully and I ran make install w/o problems. The relevant lines in my php.ini (located in /usr/local/lib) are:

[Java]
java.class.path=/usr/local/java/php_java.jar
extension_dir=/usr/local/lib
extension=libphp_java.so

I've been perusing the various online resources & archives of lists and I've tried a lot of other config lines, but I've dropped back to what it says in the README.

php_java.jar IS located in /usr/local/java
I copied libphp_java.so from my modules directory to /usr/local/lib.

I think that's it on the config. The message I get is quite simply that php can't instantiate "java". The same message many others appear to get :).

Hope I can get some help on this!
Regards,
Brice Ruth

Anon
12-27-2000, 03:22 PM
Brice,

I think you might also need to set the following in php.ini:

java.library.path=/usr/local/lib
java.library=/usr/local/java/jre/lib/i386/libjava.so

That is, the java.library.path should include the directory that contains libphp_java.so and the java.library should list the name of the actual jvm library. Make sure that what I listed above is in fact where these are (it might actually be ...i386/classic/libjava.so). I don't have my Linux box nearby to verify currently so I'm going from memory.

Another (or alternatively) thing you might have to do is:

export LD_LIBRARY_PATH=/usr/local/lib:$JAVA_HOME/jre/lib/i386:$JAVA_HOME/jre/lib/i386/native_threads:$JAVA_HOME/jre/lib/i386/classic

Again, please check the above paths for the locations of libjava.so, libjvm.so and some other stuff that libjava.so depends on (run ldd libjava.so from the command line in the directory where it is to see what I mean). BTW, you might be able to get away without setting this stuff in LD_LIBRARY_PATH but instead list all the same directories in java.library.path in php.ini.

Much of this info can be found in the <php>/ext/java/README. As far as I know that's currently the best source of information about the subject of setting up java with php. Another good source on how to actually use the feature is the zez article at http://zez.org/article/articleview/26/.

Good luck and have fun (and happy holidays!).

Alex

Anon
12-28-2000, 04:36 PM
Here's another reference to how to set up and use Java right here on this website! Albeit this is for Windoze, but the authors are working on the next article which should cover Linux.

http://www.phpbuilder.com/columns/marknold20001221.php3

Alex