Using Php-java-bridge package to implement PHP invoke Java class ____php

Source: Internet
Author: User

In the work need to convert Office document software to PDF file, look for a lot of technical discovery use OpenOffice can complete this request, but the function that call it is all Java write, all need to invoke Java class in PHP, have the following debugging process.

1, the installation of Java, this process I do not write, there are a lot of online, speaking also very fine. (In fact, you can not install, I was the original machine on the Java entire directory to save the direct use of the software to achieve green)

2, download Php-java-bridge package. Address: http://sourceforge.net/projects/php-java-bridge/files, download Javabridgetemplate621.war in binary package column. Use WinRAR decompression to find the Javabridge.jar file under Web-inf\lib.

3, use Java.exe to open this file: Java-jar Javabridge.jar (can also use the Javaw.exe after such execution can immediately exit the command window), in the pop-up window select 8080 port.

4, a new PHP file test is successful. The contents of the document are as follows:

<?php
Require_once ("Http://localhost:8080/JavaBridge/java/Java.inc");
$System = Java ("Java.lang.System");
echo $System->getproperties ();
?>

The URL address is included in the above, so you need to set the php.ini file Allow_url_include to ON.

5, edit your own Java class, and use Jar.exe packaging. Put all the required packages in the Jre7/lib/ext directory. (You need to restart Javabridge.jar when a new package is put in.)

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.