Developer on Alibaba Coud: Build your first app with APIs, SDKs, and tutorials on the Alibaba Cloud. Read more ＞
PHP and JAVA
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.
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.2in" to the AUTOEXEC. BAT file under Win9x.
Add "; C: jdk1.2.2in" to the environment variable in NT/Win2000.
This step is very important, so that PHP can correctly find the JAVA class to be called.
Step 2: modify your PHP. Ini file.
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.
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 ")."";
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 "))."";
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.
This article is an English version of an article which is originally in the Chinese language on aliyun.com and is provided for information purposes only. This website makes no representation or warranty of any kind, either expressed or implied, as to the accuracy, completeness ownership or
reliability of the article or any translations thereof. If you have any concerns or complaints relating to the article, please send an email, providing a detailed description of the concern or
complaint, to firstname.lastname@example.org. A staff member will contact you within 5 working days. Once verified, infringing content will be removed immediately.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
and provide relevant evidence. A staff member will contact you within 5 working days.