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 a powerful JAVA Class Library (classes ). For your convenience, this tutorial will include JAVA installation and some basic examples. Install JDK in windows. you only need to press enter to install JAVA. it is a very powerful programming tool and its extension Library is also very useful, this tutorial describes how to use PHP to call a powerful JAVA Class Library (classes ). For your convenience, this tutorial will include JAVA installation and some basic examples.
Installation in windows
Step 1: install JDK. this is very easy. you only need to press enter to install JDK. Perform the following steps.
Add "PATH = % PATH %; C: \ jdk1.2.2 \ bin" to the AUTOEXEC. BAT file under Win9x.
Add "; C: \ jdk1.2.2 \ bin" to the environment variable under NT.
This step is very important, so that PHP can correctly find the JAVA class to be called.
Step 2: 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.
In [java], set java. class. path to point to php_java.jar. if you use the new JAVA class, you should also store the path. In this example, we use the c: \ myclasses directory.
Step 3: Create the following php file in the Test environment:
$ 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 the installation is correct, you will see the following information:
Java version = 1.2.2
Java vendor = Sun Microsystems Inc.
OS = Windows 95 4.10 on x86
Wednesday, October 18,200 0 at 10:22:45 AM China Standard Time
In this way, we have successfully established a PHP runtime environment that can use the JAVA class, and we can start our next course.
Author: Jing Zhongyue
Re: http://www.chinalinuxpub.com/read.htm? Id = 298