PHP integration with existing Java Applications _php tutorial

Source: Internet
Author: User
Another advantage of PHP functionality is its ability to invoke methods that already have Java objects. This feature allows PHP to be integrated into existing Java-based applications. This feature is especially fashionable if you're promoting PHP at work. "Java is everywhere. ”


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

When you configure 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 typically modified in php.ini:

[Java]

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

java.class.path=/classpath/

Extension_dir=/path/to/extensions

Extension=libphp_java.so

It is up to you to remind that the above changes depend on your installation type. You should read the Readme file in the Ext/java directory under your PHP installation directory for more information about the Java feature configuration.


Here's a simple example: Create a new Java object from a PHP script. The script then accesses some Java properties and outputs them. This is as exciting as an instance of COM, but this example also lets you know more about the possible methods.

$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 must be the key to future PHP development and acceptance. So the more people who do these things, the better it will be for PHP to develop in the future.

http://www.bkjia.com/PHPjc/314481.html www.bkjia.com true http://www.bkjia.com/PHPjc/314481.html techarticle Another advantage of PHP functionality is its ability to invoke methods that already have Java objects. This feature allows PHP to be integrated into existing Java-based applications. If you are promoting in the workplace ...

  • 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.