PHP and Java (1)

zhaozj2021-02-12  135

Java is a very powerful programming tool, its expansion library is also very useful, this tutorial, mainly telling how to use the PHP call function powerful Java class library (Classes). In order to facilitate your study, this tutorial will include Java installation and some basic examples.

Installation under Windows

Step 1: Install JDK, this is very easy, you only need to install it through the way. Then do the following steps.

Add: "Path =% path%; C: JDK1.2.2bin" to the autoexec.bat file

Add "; C: JDK1.2.2bin" to environment variables under NT.

This step is very important so that PHP can find the Java class that needs to be called correctly.

Step 2: Modify your php.ini file.

[java]

EXTENSION = php_java.dll

Java.library.path = C: Webphp4extensions

Java.class.path = "C: Webphp4Extensionsionsjdk1.2.2php_java.jar; c: myclasses"

Add Extension = php_java.dll in php.ini

And in [Java], set 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 catalog.

Step 3: Test the environment, 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"). "

NN "; Print" OS = ". $ system-> getproperty (" os.name ")." "" $ system-> getproperty ("Os.Version"). "ON". $ system-> getProperty .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 are installed correctly, 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, 2000 At 10:22:45 Am China Standard Time, we have successfully established a PHP running environment that can use Java classes, we can start our next course.

转载请注明原文地址:https://www.9cbs.com/read-6600.html

New Post(0)