1. To install the Java JDK, install Tomcat
2, install the good apache,php
3. Download Php-java-bridge_5.5.4_documentation.zip
4, decompression Php-java-bridge_5.5.4_documentation.zip
5. Copy the Javabridge.war to the WebApp directory of the Tomcat server under the extracted root directory.
6. Start the Tomcat server
7. To use Java in PHP simply add the following line of statements:
OK:
$date =new Java (' java.util.Date ');
echo $date->getdate ();
?>
Run through, ok!
Call your own class, first packaged into a jar file, run in write: Jar CF Test.jar Test.java. Put it under the Tomcat publishing directory Web-inf/lib.
Test.java 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 is you!";
}else{
Rsstr = param;
}
}
Public String getString () {
return rsstr;
}
}
The PHP file is called 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
$t 1 = new Java ("Indextest");
Print ($t 1->searchword ("City", "Shanghai", "e:\\workspace\\tuan800"));
?>
Invoke the Jar file feature in the custom class that contains the import's export to package jar:eclipse, and select the project where the class you want to package is located. After packaging, place it under the web-inf/lib of the Tomcat publishing directory.
But when Lucene was replaced by 3.0.0, the package was only used to hit the class, and Lucene's core package was copied directly to the web-inf/lib of the Tomcat publishing directory.
Normal call.
Jar Package
http://repo1.maven.org/maven2/org/apache/lucene/lucene-core/3.0.0/
Search for class:
http://apps.hi.baidu.com/share/detail/5600609