Home > Backend Development > PHP Tutorial > Integrate PHP with existing Java applications_PHP Tutorial

Integrate PHP with existing Java applications_PHP Tutorial

WBOY
Release: 2016-07-21 16:09:37
Original
915 people have browsed it

Another advantage of PHP functionality is its ability to call existing Java object methods. This feature allows you to integrate PHP into existing Java-based applications. This feature is especially trendy if you're promoting PHP in the workplace. "Java is everywhere."


To achieve this feature, you need to install a Java Virtual Machine (JVM) on the server. If you will install (or have installed) a JDK from Sun, Kaffe, IBM or Blackdown, you can start working quickly.

When configuring PHP, you need to add the --with-java parameter to the configuration directive, and then modify some elements in the php.ini file. The following lines are usually modified in php.ini:

[Java]

java.library.path=/path/to/library

java.class.path=/ classpath/

extension_dir=/path/to/extensions

extension=libphp_java.so

Please note that the above modifications depend on your installation type. You should read the README file in the ext/java directory of your PHP installation to learn more about Java feature configuration.


Here is a simple example: creating a new Java object through a PHP script. The script will then access certain Java properties and output them. This is just as exciting as the COM example, but it also gives you an idea of ​​many more possible approaches.

$system = new Java("java.lang.System");

echo "

Java version = " . $system- >getProperty("java.version") . "
";

echo "Java vendor = " . $system->getProperty("java.vendor") . "

?>

If you already have Java knowledge, you should do your best to help developers on this project. Such integration capabilities will inevitably become the key to the future development and acceptance of PHP. Therefore, the more people who do these jobs, the better the future development of PHP will be.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/314481.htmlTechArticleAnother advantage of PHP functionality is its ability to call existing Java object methods. This feature allows you to integrate PHP into existing Java-based applications. If you are promoting in the workplace...
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