选择显示字体大小

连接php和 java -- php/java bridge [3]

 

安装php/java bridgexml:namespace prefix = o />

如果你用的是redhat linux系统(redhat enterprisefedora),可以从主页上下载32rpm包,然后输入rpm -i php-java-bridge-v.x.y-z-i386.rpm来安装。如果你用的是64位系统和64位虚拟机,需要安装64rpm包。其它系统看下面的介绍。

(1) 安装php/java bridge之前,你需要确定已经安装了:
java1.4
或更高版本,
gcc3.2
或更高版本,
apache1.3
或更高版本,
autoconf2.57
或更高版本,done
libtool 1.4.3
或更高版本, done
automake1.6.3
或更高版本,
gnu make done
php4.3.2
或更高版本

你可以用命令java -version, gcc --version, apachectl -version, libtool --version, automake --version, make null --version, autoconf --version and php-config –version来确定这些软件包的版本。

(2) 下载php/java bridge的源代码
http://www.sourceforge.net/projects/php-java-bridge

(3)
解压缩:cat php-java-bridge_v.x.y.tar.bz2 bunzip2 tar xf –

(4)

在解压缩出来的目录php-java-bridge-v.x.y里执行命令:

phpize && ./configure --disable-servlet --with-java=/opt/ibmjava2-14 && make cflags="-m32"

32jvm生成模块。

(5)安装生成的模块
su -c 'make install'
<enter password>

(6) php/java bridge可以作为web服务器sub-component运行,把下面这行加入到php.ini中,或者把这一行写到一个文件java.ini,再把java.ini复制到包含php模块描述的目录中去,如/etc/php.d/

extension = java.so
[java]

(7)重启apache服务器/www/apache/bin/apachectl restart

(8)现在开始可以测试web安装。复制test.php到站点根目录下( /var/www/html),通过浏览器访问。你可以看到bridge模块已经激活并正在运行。bridge会随着服务器的启动而启动。

test.php

<?php

phpinfo();

print "\n\n";

 

$v = new java("java.lang.system");

$arr=$v->getproperties();

foreach ($arr as $key => $value) {

  print $key . " -> " .  $value . "<br>\n";

}

?>

windows平台下的安装:

<!--[if !supportlists]-->1.              <!--[endif]-->解压缩php-java-bridge_2.0.4-win32-php5.zip,复制所有文件到c:\php

<!--[if !supportlists]-->2.              <!--[endif]-->双击c:\php5\javabridge.jar或者在命令行执行java -jar javabridge.jar

<!--[if !supportlists]-->3.              <!--[endif]-->php-cgi test.php >result.html    (test.php源码见上例)

<!--[if !supportlists]-->4.              <!--[endif]-->用浏览器打开result.html,即可看到运行结果

 

测试程序首先把php环境的所有选项输出,然后新建了一个java对象并返回它的相关信息。

 

运行结果:

xml:namespace prefix = v />aspectratio="t"><!--[if !vml]--><!--[endif]-->

 

java.runtime.name -> java(tm) 2 runtime environment, standard edition
sun.boot.library.path -> c:\program files\java\j2re1.4.2_05\bin
java.vm.version -> 1.4.2_05-b04
java.vm.vendor -> sun microsystems inc.
java.vendor.url -> http://java.sun.com/
path.separator -> ;
java.vm.name -> java hotspot(tm) client vm
file.encoding.pkg -> sun.io
user.country -> cn
sun.os.patch.level -> service pack 2
java.vm.specification.name -> java virtual machine specification
user.dir -> c:\php
java.runtime.version -> 1.4.2_05-b04
java.awt.graphicsenv -> sun.awt.win32graphicsenvironment
java.endorsed.dirs -> c:\program files\java\j2re1.4.2_05\lib\endorsed
os.arch -> x86
java.io.tmpdir -> c:\docume~1\506c\locals~1\temp\
line.separator ->
java.vm.specification.vendor -> sun microsystems inc.
user.variant ->
os.name -> windows xp
sun.java2d.fontpath ->
java.library.path -> c:\program files\java\j2re1.4.2_05\bin;.;c:\windows\system32;c:\windows;c:\j2sdk1.4.2_05\bin;.;c:\j2sdk1.4.2_05\lib;c:\j2sdk1.4.2_05\jre\lib;c:\program files\securecrt 3.0;c:\windows\system32;c:\program files\chemoffice2002\common\dlls
java.specification.name -> java platform api specification
java.class.version -> 48.0
java.util.prefs.preferencesfactory -> java.util.prefs.windowspreferencesfactory
os.version -> 5.1
user.home -> c:\documents and settings\506c
user.timezone ->
java.awt.printerjob -> sun.awt.windows.wprinterjob
file.encoding -> gbk
java.specification.version -> 1.4
java.class.path -> c:\php\javabridge.jar
user.name -> 506c
java.vm.specification.version -> 1.0
java.home -> c:\program files\java\j2re1.4.2_05
sun.arch.data.model -> 32
user.language -> zh
java.specification.vendor -> sun microsystems inc.
awt.toolkit -> sun.awt.windows.wtoolkit
java.vm.info -> mixed mode
java.version -> 1.4.2_05
java.ext.dirs -> c:\program files\java\j2re1.4.2_05\lib\ext
sun.boot.class.path -> c:\program files\java\j2re1.4.2_05\lib\rt.jar;c:\program files\java\j2re1.4.2_05\lib\i18n.jar;c:\program files\java\j2re1.4.2_05\lib\sunrsasign.jar;c:\program files\java\j2re1.4.2_05\lib\jsse.jar;c:\program files\java\j2re1.4.2_05\lib\jce.jar;c:\program files\java\j2re1.4.2_05\lib\charsets.jar;c:\program files\java\j2re1.4.2_05\classes
java.vendor -> sun microsystems inc.
file.separator -> \
java.vendor.url.bug -> http://java.sun.com/cgi-bin/bugreport.cgi
sun.io.unicode.encoding -> unicodelittle
sun.cpu.endian -> little
sun.cpu.isalist -> pentium i486 i386

 

到这里,我们就可以自由地和java对象进行通讯,实现了phpjava的桥接。

<!--[if !supportlists]-->5.              <!--[endif]-->接下来修改你的php.inic:\windows\php.ini),把extension=php_java.dll前的分号;去掉

注意, php也自带有一个php_java.dll,位于c:\php\extensions下,和php-java-bridge提供的不一样。为避免出错,要注意设置php.ini中的extension_dir ,默认extension_dir = "./"即指向c:\php目录。


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons