PHP 调用java
来源:互联网 发布:联通首选网络类型 编辑:程序博客网 时间:2024/06/06 19:16
原文:http://php-java-bridge.sourceforge.net/pjb/webapp.php
如果需要使用自己编写的java类,只需把工程打成jar包,按照第二步加入到war包中即可。
Create a simple Java web application.
- Download the zip file JavaBridgeTemplate.war to some local directory.
- Open the zip file for example with "winzip" or "file-roller" and add itext.jar to its WEB-INF/lib folder.
- Rename JavaBridgeTemplate621.war to ExcelCreator.war and copy it to your JEE deployment folder. Restart your JEE server, if necessary.
- Wait a few seconds until the web application "ExcelCreator" appears.
Test your Java web application
- Create a PHP test script. For example:
<?php require_once("http://localhost:8080/ExcelCreator/java/Java.inc");
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=downloaded.xls");
// create a 50x40 excel sheet and return it to the client
$workbook = new java("org.apache.poi.hssf.usermodel.HSSFWorkbook");
$sheet = $workbook->createSheet("new sheet");
for($y=0; $y<40; $y++) {
$row = $sheet->createRow($y);
for($x=0; $x<50; $x++) {
$cell = $row->createCell($x);
$cell->setCellValue("cell $x/$y");
}
}
// create and return the excel sheet to the client
$memoryStream = new java("java.io.ByteArrayOutputStream");
$workbook->write($memoryStream);
$memoryStream->close();
echo java_values($memoryStream->toByteArray());
?> - Run your test script. For example with:
php -n -dallow_url_include=On test.php >result.xls
- Your PHP script has called the web application "ExcelCreator" with a custom PHP script, to create a custom XLS file.
For further information please read the INSTALL.J2EE documentation from the documentation download file.
- php中调用java
- PHP中调用JAVA,
- php中调用java
- php 调用 java webservice
- php 调用 java webservice
- solr调用 java php
- PHP 调用java
- php调用JAVA
- PHP调用Java Webserver
- Php调用java
- php调用java
- php调用JAVA
- javaBridge php调用java
- Java调用PHP 实例
- Java 调用 PHP 实例
- PHP调用Java WebService
- php 调用java php-java-bridge
- PHP 如何调用 JAVA 类库
- [学习笔记]信息系统开发
- 嵌入式Linux编译器gcc使用
- 读书笔记_栈
- ref 与 out 参数
- maven 插件配置汇总小计
- PHP 调用java
- 黑马程序员——使用equals实现对象的比较
- linux解压 tar命令
- 一段最短的代码,用上js所有关键字
- socket 与 mina 交互数据
- Memcached--分布式缓存
- PHP cookie session
- webm convert
- 算法导论-第19章-二项堆