Integration of PHP with existing Java applications

Source: Internet
Author: User
PHP is integrated with existing Java applications, and PHP is integrated with existing Java applications. another advantage of PHP is its ability to call existing Java object methods. This function can be used to integrate PHP into existing Java-based applications. This feature is especially trendy if you are promoting PHP at work. "Java is everywhere ." Actual "> <LINKhref =" http :/

Another advantage of PHP is its ability to call existing Java object methods. This function can be used to integrate PHP into existing Java-based applications. This feature is especially trendy if you are promoting PHP at work. "Java is everywhere ."


To implement this function, you need to install the Java virtual machine (JVM) on the server ). If you want to install (or have installed) JDK from Sun, Kaffe, IBM, or Blackdown, you can get started quickly.
 
When configuring PHP, add the -- with-java parameter to the configuration command and modify some elements in the php. ini file. Modify the following lines in php. ini:

[Java]

Java. library. path =/path/to/library

Java. class. path =/classpath/

Extension_dir =/path/to/extensions

Extension = libphp_java.so
 

Note that the above modifications depend on your installation type. Read the README file in the ext/java directory of your PHP installation directory to learn more about Java function configuration.


Here is a simple example: create a new Java object using a PHP script. The script then accesses some Java attributes and outputs them. This is as exciting as the COM instance, but this example also gives you more possibilities.

$ 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 in this project. Such integration capabilities will inevitably become the key to PHP development and human acceptance in the future. Therefore, the more people who do these jobs, the better the future development of PHP.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.