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.2bin "to Autoexec.bat file
Under NT, add "; C:jdk1.2.2bin "into the environment variable.
This step is important so that PHP can correctly find the Java class that needs to be called.
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"). "
nn ";
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.
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:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.