Home Backend Development PHP Tutorial php and java (1)_PHP tutorial

php and java (1)_PHP tutorial

Jul 20, 2016 am 11:04 AM
java php one and main sharp weapon Library powerful Expand Tutorial it works of programming

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 (classes). 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.2 in" to the AUTOEXEC.BAT file under Win9x
Add ";C:jdk1.2.2 in" to the environment variable under NT .
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 to PHP.INI
and in [java], set java.class.path so that it points to php_java.jar. If you use the new JAVA class, you should also Save 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")."
";
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 you installed it 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
In this way, we have successfully established a PHP operating environment that can use JAVA classes, and we can start our next course.
Author: Jing Zhongyue
Reprinted:

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445237.htmlTechArticleJAVA is a very powerful programming tool, and its extension library is also very useful. This tutorial mainly talks about how to Use PHP to call powerful JAVA class libraries. For your convenience...
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

Hot Article

Hot Article

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

How To Set Up Visual Studio Code (VS Code) for PHP Development

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

PHP Program to Count Vowels in a String

Break or return from Java 8 stream forEach? Break or return from Java 8 stream forEach? Feb 07, 2025 pm 12:09 PM

Break or return from Java 8 stream forEach?

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

How do you parse and process HTML/XML in PHP?

Problem-Solving with Python: Unlock Powerful Solutions as a Beginner Coder Problem-Solving with Python: Unlock Powerful Solutions as a Beginner Coder Oct 11, 2024 pm 08:58 PM

Problem-Solving with Python: Unlock Powerful Solutions as a Beginner Coder

Java Made Simple: A Beginner's Guide to Programming Power Java Made Simple: A Beginner's Guide to Programming Power Oct 11, 2024 pm 06:30 PM

Java Made Simple: A Beginner's Guide to Programming Power

Demystifying C: A Clear and Simple Path for New Programmers Demystifying C: A Clear and Simple Path for New Programmers Oct 11, 2024 pm 10:47 PM

Demystifying C: A Clear and Simple Path for New Programmers

See all articles