PHP Implementation and java Plug in Use Tutorial
- 2021-12-19 06:00:20
- OfStack
Due to the company this project needs and java docking of a few things and do not want to use webservice so got an php module tossed a long time to compile 1 straight through. Simply modified the source code. After testing usable. In addition, I attached a copy of the installation record to let everyone walk less than a detour
In addition, this thing needs to install java and download it directly from official website
The system version is centos 7 x64
PHP 5.4.x
Compile and install php-java-bridge module
Download package:
PHP-JAVA-BRIDGE
Compile and install:
Extract php-java-bridge, enter the directory of php-java-bridge, and compile php-java-bridge into an extension of php
tar -xzf php-java-bridge-5.4.3.1.new.tar.gz
cd php-java-bridge-5.4.3.1
/usr/local/php/bin/phpize
./configure --disable-servlet --with-java=/usr/java/jdk1.8.0_91,/usr/java/jdk1.8.0_91/jre --with-php-config=/usr/local/php/bin/php-config
make
make install
/usr/java/jdk1.8.0_91/jre/bin/java -classpath /usr/local/php/lib/php/extensions/no-debug-zts-20100525/JavaBridge.war TestInstallation
This command is best booted
php. ini added
extension=java.so
[java]
;java.hosts = 127.0.0.1:8080
;java.servlet = On ;; Off, On or User
java.log_level = 3
Restart
php-fpm apache nginx
Copy Java. inc and put it into the website directory to call OK
/usr/local/php/lib/php/extensions/no-debug-zts-20100525/java/Java.inc
Modification:
define ("JAVA_HOSTS","127.0.0.1:8080");
// define ("JAVA_PERSISTENT_SERVLET_CONNECTIONS",true);
// define ("JAVA_PREFER_VALUES",1);
define ("JAVA_DEBUG",false);
define ("JAVA_PIPE_DIR","/data/test/java-tmp"); // This is the cache file address
// http://c.3viso.cn/java.php This is 1 Test applet
#!/usr/bin/php
<?php
require_once("Java.inc");
$system=new java("java.lang.System");
print "Java version=".$system->getProperty("java.version")." ";
$str=new Java("java.lang.String");
echo $str;
Summarize
The above is the site for you to collect collated PHP and java communication plug-in all content, I hope the article can help you solve the PHP and java communication plug-in program development problems encountered.