Java extension in PHP. Java's scalability is one of its extremely exciting uses. by learning how to use this module, you can expand all available Java classes. To enable you to understand Java scalability Java's scalability is one of its extremely exciting uses. by learning how to use this module, you can expand all available Java classes. To help you understand the basics of Java scalability, this article includes system installation and some code examples used together with PHP and Java.
Install in Windows
The following configuration is based on Apache 1.3.12, PHP 4.0.3 (you can download it at www.php4win.de), and JDK1.2.2 (you can download it at java.sun.com ). We have tried this installation configuration in the older versions of JDK and Windows 95, Windows 98 and NT4, and various MS webservers (PWS and IIS.
Step 1: install JDK
This process should be simple, because there are not many problems with JDK installation, but you need to check your system environment (in Windows9X, autoexec. "system" in "control panel" in bat and NT environments) and confirm JDK1.x. whether the xin path is loaded into the path. This setting will make it easier for you to compile Java classes. Add in Win9x
PATH = % PATH %; C: jdk1.2.2in
Add autoexec. bat to your system in NT
C: jdk1.2.2in
To the end of the Path environment variable. In the system, the autoexec. bat annotation is very important. The Java extension of PHP will ignore the installation paths of JAVA_HOME and CLASSPATH in the system. In this way, setting these projects correctly in php. ini is very important.
Step 2: modify your php. ini
Add the following items to your php. ini file:
[Java]
Extension = php_java.dll
Java. home = C: jdk1.2.2
Java. library = c: jdk1.2.2jreinCLASSICjvm. dll
Java. library. path = c: webphp4extensions
Java. class. path = "c: webphp4extensionsjdk1.2.2php _ java. jar; c: myclasses"
The representative problem is that some people will put extension = php_java.dll and other extensions in php. INI files are put together, but the correct position should be in php. under [java] in the INI file. Java. library. path must be set in php_java.dll, and the java. class. path must contain the path of php_java.jar. Java. class. path must be added to other paths of other classes that you may use. for example, c: myclasses in the above example, or you can write only the preceding paths.
Step 3: Test your installation results
Now, you can create a php program similar to this:
$ 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 ")."".
$ System-> getProperty ("OS. version"). "on ".
$ System-> getProperty ("OS. arch ")."
";
$ Formatter = new Java ("java. text. SimpleDateFormat", "EEEE,
MMMM dd, yyyy at h: mm: ss a zzzz ");
Print $ formatter-> format (new Java ("java. util. Date "))."";
?>
This is an example of Sam Ruby. If you set none of them, you will see the result as follows:
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
Note:
Java version = 1.2.2
Java vendor = Sun Microsystems Inc.
OS = Windows 95 4.90 on x86
Wednesday, March 13, 2001 at 1:44:33 GMT +)
This is a very simple example, but it can tell you how to access the java class with php. once you can turn this example up, it indicates that your php java extension has been installed successfully.
Bytes. To help you understand Java scalability...