Bridge between php and java-javabridge

Source: Internet
Author: User
Php and java Bridge-javabridge2008-03-0517: 26 due to project needs, must use php to call java, tried two ways to bridge (local test, windows) :. use the php module php_java.dll1. configure php. remove the INI file; ext php and java Bridge -- javabridge
Due to project needs, you must use php to call java, tried two ways of bridging (local test, windows) one :. use the php module php_java.dll1. configure php. remove the INI file; semicolon [java] java before extension = php_java.dll. library = E: \ project \ eclipse \ jre \ bin \ client \ jvm. dlljava. home = E: \ project \ eclipse \ jre \ java. library. path = E: \ project \ xampp \ php \ ext \ java. class. path = E: \ project \ xampp \ php \ ext \ php_java.jar where java. library is the path of the java virtual machine, java. home is the java path, java. library. path is the extension path of php, java. class. path is the path of php_java.jar 2. restart apache3. test code try {$ system = new Java ('Java. lang. system '); // demonstrate property access echo 'Java version = '. $ system-> getProperty ('Java. version ').'
'; Echo 'Java vendor ='. $ system-> getProperty ('Java. upload ').'
'; Echo' OS = '. $ system-> getProperty ('OS. name '). ''. $ system-> getProperty ('OS. version '). 'on '. $ system-> getProperty ('OS. arch ').'
';} Catch (JavaException $ e) {echo $ e-> getCause ();} test result: Java version = 1.5.0 _ 09 Java vendor = Sun Microsystems Inc. OS = Windows XP 5.1 on x86 note: apache died during the php5 test and php4 could run. the specific cause was not found. it is estimated that it could not be loaded to Java Virtual Machine 2: Download php-java-bridge_5.2.0_j2ee.zip with JavaBridge. war, available winrar decompress in JavaBridge \ WEB-INF \ lib has a JavaBridge. jar file. use the command line to call java-jar JavaBridge. jar or double-click JavaBridge. jar, select listening port 2 in the pop-up window. copy the entire java folder in JavaBridge to the PHP file directory. test require_once ("java/java. inc "); try {$ system = new Java ('Java. lang. system '); // demonstrate property access echo 'Java version = '. $ system-> getProperty ('Java. version ').'
'; Echo 'Java vendor ='. $ system-> getProperty ('Java. upload ').'
'; Echo' OS = '. $ system-> getProperty ('OS. name '). ''. $ system-> getProperty ('OS. version '). 'on '. $ system-> getProperty ('OS. arch ').'
';} Catch (JavaException $ e) {echo $ e-> getCause ();} test result: Java version = 1.5.0 _ 09 Java vendor = Sun Microsystems Inc. OS = Windows XP 5.1 on x86, the basic php and java bridging is basically completed.

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.