How to call JAVA_PHP tutorial in PHP

WBOY
Release: 2016-07-13 10:27:22
Original
866 people have browsed it

Detailed description: http://php.662p.com/thread-275-1-1.html

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 powerful JAVA class libraries. To facilitate your learning, this tutorial will include JAVA installation and some basic examples.

Installation under windows

Step one: Install JDK, this is very easy, you only need to press Enter all the way to install it. Then do the following steps.

Add: "PATH=%PATH%;C:jdk1.2.2bin" to the AUTOEXEC.BAT file under Win9x.

Add ";C:jdk1.2.2 under NT/Win2000" bin" to the environment variable.

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

Step 2: Modify your PHP.INI file.

[java]

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 in PHP.INI

and set java.class in [java] .path, let it point to php_java.jar. If you use new JAVA classes, you should also save it in this path. In this example, we use the c:myclasses directory.

Step 3: 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 installed it correctly, you will see the following message:

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

In this way, we have successfully established a PHP operating environment that can use JAVA classes, and we can start our next course.

Detailed description: http://php.662p.com/thread-275-1-1.html

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/819972.htmlTechArticleDetailed description: http://php.662p.com/thread-275-1-1.html 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...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!