Detailed Description: http://php.662p.com/thread-275-1-1.html
PHP and Java
Java is a very powerful programming tool, its extension library is also very useful, this tutorial, mainly on how to use PHP to call the powerful Java class Library (classes). To facilitate your learning, this tutorial will include Java installation and some basic examples.
Installation under Windows
The first step: Install the JDK, which is very easy and you just have to get all the way back to the installation. Then do the following steps.
Added under Win9x: "path=%path%; C:\jdk1.2.2\bin "to Autoexec.bat file
Under nt/win2000, add "; C:\jdk1.2.2\bin "into the environment variable.
This step is important so that PHP can correctly find the Java class that needs to be called.
Step Two: Modify your php.ini file.
[Java]
Extension=php_java.dll
Java.library.path=c:\web\php4\extensions\
Java.class.path= "C:\web\php4\extensions\jdk1.2.2\php_java.jar;c:\myclasses"
Add Extension=php_java.dll to PHP.ini
And in [Java], set the good java.class.path, let it point to Php_java.jar, if you use the new Java class, you should also deposit this path, in this example, we use c:\myclasses this directory.
Step three: Test the environment and create the following PHP file:
$system = new Java ("Java.lang.System");
Print "Java version=". $system->getproperty ("Java.version"). " \ n ";
Print "Java vendor=". $system->getproperty ("Java.vendor"). " \ n ";
Print "os=". $system->getproperty ("Os.name"). " ".
$system->getproperty ("Os.version"). "On".
$system->getproperty ("Os.arch"). " \ n ";
$formatter = new Java ("Java.text.SimpleDateFormat", "eeee,
MMMM dd, yyyy ' at ' h:mm:ss a zzzz ");
Print $formatter->format (new Java ("Java.util.Date")). " \ n ";
?>
If you install it correctly, you will see the following information:
Java version=1.2.2
Java Vendor=sun Microsystems Inc.
Os=windows 4.10 on x86
Wednesday, October, at 10:22:45
In this way, we have successfully built a PHP runtime environment that can be used with Java classes, and we can start our next course.
Detailed Description: http://php.662p.com/thread-275-1-1.html
http://www.bkjia.com/PHPjc/819972.html www.bkjia.com true http://www.bkjia.com/PHPjc/819972.html techarticle http://php.662p.com/thread-275-1-1.html PHP and Java Java is a very powerful programming tool, its extension library is also very useful, this tutorial, mainly about how to use ...