[Reprint] phpjava interaction phpjavabridge 1. Install java jdk and tomcat
2. install apache and php
3. download php-java-bridge_5.5.4_documentation.zip
4_decompress php-java-bridge_5.5.4_documentation.zip
5. copy JavaBridge. war under the root directory after decompression to the webapp Directory of the tomcat server.
6. start the tomcat server
7. to use java in php, you only need to add the following line of statements:
Yes:
$ Date = new Java ('Java. util. date ');
Echo $ date-> getDate ();
?>
Run successfully, OK!
Call your own class, first package it into a jar file, and write: jar cf Test. jar Test. java during running. Put the tomcat release directory WEB-INF/lib.
Test. java is as follows:
Public class Test {
Public String rsStr;
Public static void main (String [] args)
{
System. out. println ("Hello World! ");
}
Public void setString (String param ){
If (param. equals ("")){
RsStr = "Hello, how are you! ";
} Else {
RsStr = param;
}
}
Public String getString (){
Return rsStr;
}
}
The PHP file called is as follows:
$ T = new java ("Test ");
Echo get_class ($ t );
$ T-> setString ("ffffffffffff ");
Echo $ t-> getString ();
// Echo "ddjsa; fjsjf; sja; fl ";
$ T-> setString ("dddddddddddddddd ");
Echo $ t-> getString ();
$ T-> setString ("33333333333333333333 ");
Echo $ t-> getString ();
// ******************************** My jar
$ T1 = new java ("IndexTest ");
Print ($ t1-> searchWord ("city", "Shanghai", "E: \ workspace \ tuan800 "));
?>
Call the jar file function of jar: export of eclipse that contains import in the custom class, and select the project of the class to be packaged. Package it and put it under the tomcat release directory of the WEB-INF/lib.
But lucene into version 3.0.0, packaging only class, lucene core package directly copy to tomcat release directory of the WEB-INF/lib.
Normal call.
Jar package
Http://repo1.maven.org/maven2/org/apache/lucene/lucene-core/3.0.0/
Search class:
Http://apps.hi.baidu.com/share/detail/5600609