725Chapter 39PHP and JavaJava support is (Best web design) not enabled
725Chapter 39PHP and JavaJava support is not enabled by default, and you will need to rebuild PHP in order to takeadvantage of its features. During the installation, you must specify the option with- java=(basedirectory)in addition to any other options you may require. (See Chapter 3for more information on building and installing PHP.) Modifications are also required to the php.iniconfiguration file in order to enable the exten- sion. Open your php.inifile in your favorite editor and search for the [Java]subheadingunder Module Settings. Here s where the information you collected earlier will come inhandy. A typical modification on a Linux server might look something like this: [java] java.home = /usr/java/j2sdk1.4.0java.library = /usr/java/j2sdk1.4.0/jre/lib/i386/libjava.sojava.library.path = /usr/lib/php/extensions/no-debug-non-zts- 20020429extension_dir = /usr/lib/php/extensions/no-debug-non-zts- 20020429extension=libphp_java.soWindows users should also add the following line under Windows Extensions: extension=php_java.dllJust to add some confusion for fun, note that the java.libraryvariable pertains to theJava installation, while java.library.pathrefers to the PHP extension directory wherethe optional PHP support files reside. Most problems with getting the Java extension to workseem to revolve around successfully editing php.ini. Remember that these variables must correspond to the settings on your particular server. Windows users must be sure to enclose the path names in quotations. If all goes well, you should be ready to try calling a Java method from within PHP! TestingA simple invocation of java.lang.Systemin a JSP environment would look something like this: <% String version = System.getProperty( java.version ); String os = System.getProperty( os.name ); %>
We are running Java version <%= version %> on the <%= os %> platform, and it s working!
CautionNote44From our experience, we can recommend PHP5 Web Hosting services, if you need affordable webhost to host and run your web application.