JAVA is a very powerful programming tool, and its extension library is also very useful. This tutorial mainly describes how to use PHP to call powerful JAVA class libraries. To facilitate your learning, this tutorial will include JAVA installation and some basic examples.
Installation under windows
Step one: Install JDK, this is very easy, you only need to press Enter all the way to install it. Then do the following steps.
Add: "PATH=%PATH%;C:jdk1.2.2 in" to the AUTOEXEC.BAT file under Win9x
Add ";C:jdk1.2.2 in" to the environment variable under NT .
This step is very important so that PHP can correctly find the JAVA class that needs to be called.
Step 2: Modify your PHP.INI file.
[java]
extension=php_java.dll
java.library.path=c:webphp4extensions
java.class.path="c:webphp4extensionsjdk1.2.2php_java.jar;c:myclasses"
Add extension=php_java.dll to PHP.INI
and in [java], set java.class.path so that it points to php_java.jar. If you use the new JAVA class, you should also Save this path. In this example, we use the c:myclasses directory.
Step 3: Test the environment and create the following PHP file:
$system = new Java("java.lang.System");
print "Java version=".$ system->getProperty("java.version")."
";
print "Java vendor=".$system->getProperty("java.vendor")."
";
print "OS=".$system->getProperty("os.name")." ".