Practical tips: two methods for calling Java classes in PHP

Source: Internet
Author: User
The Java Language is powerful, so the function of calling Java in php in many cases will be very useful. There are two methods to call the Java language in php: one is to use the Java expansion module in php, and the other is to use the SJOP protocol provided by the server by the application of minij2ee. Next we will compare the characteristics of the two methods

The Java Language is powerful, so the function of calling Java in php in many cases will be very useful. There are two methods to call the Java language in php: one is to use the Java expansion module in php, and the other is to use the SJOP protocol provided by the server by the application of minij2ee. Next we will compare the characteristics of the two methods.

1. Java Module of php

Php announced that the version contains a Java extension module that can be used to call Java objects. for example:


 getProperty('java.version').' 
\n';?>

The advantage of using this method is that it is more convenient. as long as you use new Java () to create a Java object, you can call the Java object like the php class. However, this method also has the following obvious problems:

1. because the Java Module of php selects the most appropriate Java method based on the data type of php, it cannot call Java overload functions.

2. the Java Module of php will be loaded into JVM (Java virtual machine) during the current Web Server process. Therefore, the system overhead is extremely high, which affects the performance efficiency of the Web Server process.

3. in some control systems and Web Server environments, the Java Module of php will make the Web Server process stiff.

For these reasons, the Java Module of php has been unable to use the actual software system.

2. minij2ee is implemented using the server SJOP protocol

Before minij2ee is implemented using the SJOP protocol of the server, let's take a look at how minij2ee uses the server. Minij2ee exploitation server is the first J2EE exploitation server product supporting php, enabling php to be used for enterprise-level exploitation system development. The full name of SJOP is Sample Java ORB Protocol (simple Java Object request proxy Protocol), is a simple and efficient object request proxy Protocol. For example:


 \n';?>

Minij2ee using the server to achieve the SJOP protocol is an important goal is to enable php to visit EJB enterprise-level components, so minij2ee provides a EJB-PHP compiler, can compile EJB components into php class, this allows php programs to conveniently call EJB components, for example:


 Create ($ cart_name); file: // create Cart EJB. $ Cart = new Cart ($ objref); $ cart-> add ('Some goods '); file: // add an item to the cart.?>

Using the php support of the server, the application minij2ee can develop an object-oriented, stable and efficient enterprise-level exploitation system based on php and J2EE skills.

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.