You probably already know that PHP comes with extensions for awide variety of different technologies. But did you know that you couldhook PHP up to Java, and use Java classes and Java Beans from withinyour PHP scripts? If this is news to you, keep reading.
PHP doesn't come with Java support turned on by default, so you'll need to recompile it to enable this support. You can do this by adding the "--with-java" compile-time parameter to the PHP "configure" script. Note that you'll also need a copy of the latest JDK - you can get this from http://java.sun.com/ (the examples in this article use version 1.3.0 of the JDK).
If you're using Windows, you've already got a pre-built Java extension with your PHP distribution - all you need to do is enable it. First, make sure that your system's PATH variable includes the path to the JDK - this can easily be accomplished by altering the PATH variable in your "autoexec.bat" file.
Next, pop open the "php.ini" configuration file, and skip over all the cryptic configuration commands to the "Java" section. There, set values for the following variables:
java.library - this refers to the location of the Java Virtual Machine file (jvm.dll), usually located in the JRE directory;
java.library.path - this refers to the location of PHP's Java extension;
java.home - this refers to the JDK's "bin" directory;
java.class.path - this refers to the Java CLASSPATH, which contains your custom Java classes. You should make sure that this variable always includes the location of the "php_java.jar" file (usually the /java/ directory)
While you're editing this file, also drop by the "Windows Extensions" section of "php.ini" and uncomment the "php_java.dll" extension.
Finally, check to make sure that the file "php_java.dll" is in the /extensions/ sub-directory, restart your Web server, and you're ready to roll!