PHP4 call JavaBean exploration Author: Anonymous Published: 2004-6-16 12:18:47
First, declare, when I wrote this article, I don't understand this, but I have undergone example from php.net, try to do it, and is under Win2000 Apache PHP4P12 configuration. The specific steps are as follows: 1. Installation JVM (Java Virtual Machine) (I use JDK122) Of course, you don't have to use JDK122, not even JDK, with other, such as: JVM = kaffe 1.0.4 (as delivered with os), OS = redhat Linux 6.1 JVM = kaffe 1.0.5 (Built from Source), OS = Redhat Linux 6.1 JVM = IBM 1.1.8, OS = Redhat Linux 6.1 JVM = Blackdown 1.2.2 RC4, OS = Redhat Linux 6.1 JVM = Sun JDK 1.1.8, OS = Windows NT 4 / Win2000, but I only said to my approach, I haven't tried it, don't ask me, here to pay special attention, according to the official website of the PHP, I don't support JDK122 Linux two Setting the environment variable "My Computer" -> Properties "->" Advanced "-> Environment Variables" Set Java_Home is: JDK122 is installed in E: JSPJDK122, then set to E: JSPJDK122 three, download related files (if you have no words) download address: http://www.php.net/downloads.php I downloaded: PHP-4.0.1-win32-java-jdk122.zip file, unzipped There are several examples, and there are: php_java.dll and php_java.jar files. Four, configure php.ini files [java] java.class.path = E: php4php_java.jar java.home = E: jspjdk122bin extension = php_java. DLL java.library.path = E: PHP4ext java.library = E: Program filesjavasoftjre1.2binclassicjvasoftjre1.2binclassicjvm.dll is my configuration, explain, my php4 is in the E: PHP4 directory, all of my extended DLL files E: PHP4EXT directory, of course, php_java.dll should copy to this directory. Finally confirm you There is a jvm.dll file in win2000, if not, install Visual Studio (I installed a VC 6, so I don't have to consider) 5. The test runs phpinfo () can see "java". If not, you have no success. It shows the following: Java Directive local value master value java.class.path E: php4php_java.jar E: php4php_java.jar java.home E: JSPJDK122BIN E: JSPJDK1222BIN JAVA.LIBRARY E: Program FILESJAVASOFTJRE1.2BINCLASJAVM.DLL JVM.DLL JAVA.LIBRARY.PATH E: PHP4EXT No Value 6. I use the example of the downloaded files: jver.php, if success, there will be the following results: Java Version = 1.2 .2 java vendor = sun microsystems Inc. OS = Windows NT 5.0 on x86 Wednesday, July 19, 2000 AT 10:32:53 afternoon GMT 08: 00 Seven, again, I have encountered two specific and again Is a problem that must be solved:
(A) how to write their own call javabean (two) IIS win2000 php4p12 has not been successful in these questions, please predecessors pointing lower, would be grateful PHP4 call JavaBean exploration (cont.) Author:! Anonymous Published: 2004 -6-16 12:11:21
Written "PHP4 call Javabean's exploration", then I want to try the Javabean written by yourself, how can you not teach a lot, I finally understand, here I want to thank Liao Yang, in fact, I am not familiar with him. However, he did give me a lot of help. Declare that the following examples are implemented under Win2000 / IIS5 / CGI / PHP4DEV2 / JDK13. Below I add a few simple examples in the previous article. Supplement: Next good PHP4 version, I have always liked the PHP4 version under http://www.mm4.de/. After downloading, it took a php.ini and has supported Java. You add your own Java Class directory in java.class.path, such as: f: php4class, you will do your own Java Class. With its "root" (Package with Java, it is built here), and some simple example shows great "Hello World!" To write a simple Java file (I am using Liao Yang here. Example, in order to express your gratitude, I didn't do any changes) Test1.java files as follows: package tests; public class test1 {public string getMessage () {return "Hello World";}} Generate Test1.class files with Javac Test1.java In the Test1.class copy to f: php4class's Tests subdirectory (here is the need of Java Package), getMsg.php4 files are as follows: $ B = new java ("tests.test1"); $ x = $ b-> getMessage (); echo $ x;> Accessing getMsg.php4 in the browser will display "Hello World!" and give an example: Test.java file content is as follows: import java.lang. *; Public class test {public int RET_TEST (INT i) {if (i> 0) RETURN 31; if (i == 0) Return 30; if (i <0) return 29; return 100;}} is compiled after F : PHP4CLASS directory, name is of course: test.class write a php4 file Testint.php4 as follows: $ b = new Java ("TEST", "); $ x = $ b-> RET_TEST (4); Echo $ x;?> Access will display 31. Later, I made a Javabean called the SQL database. Everything in PHP4 is normal. You can try it yourself. It is true. From a certain extent, it can be said that "hidden source code" is achieved. Interested friends are welcome.