Stuck again!
I have installed MySQL (4.0.21) with Apache (2.0.52), and
PHP 5.0.2 and successfully integrated them on a Windows XP
system. I am trying to add the Java extension, using the pecl
5.1.2 Win32 download. (Thanks to Pieman60 and Houdini)

After the customary changes in php.ini defining system paths
and setting java.library.path, java.class.path, java.home, and
java.library, I get the following message upon starting up the
Apache server:

"c:\php5\ext\php_java.dll module could not be found."

The mystery is that this file is in fact located in
c:\php5\ext. (As a matter of interest, I sprinkled php_java.dll
in many possible locations and still the system can't seem to
find it. )
Am I misinerpreting the meaning of the message? For example it
may find it but can't run it?
Thanks for any clues to get the mystery solved.
Paul

    That message could mean that the extension is missing an additional dll. How das the java configuration part in your php.ini look like ?

    Thomas

      Hello Thomas,
      Here is a copy of the java confi part of php.ini:

      ;extension=php_yaz.dll
      ;extension=php_zip.dll
      extension=php_java.dll

      [java]
      ;This must point to the location of php_java.dll.
      java.library.path = "c:\php5\ext\"

      ;This points to the directory where your java
      ;classes will be stored. You can designate multiple
      ;paths, each path separated by a semicolon.
      ;It also must include the location of php_java.jar
      java.class.path = "c:\php5\jdk1.5.0_06\php_java.jar;
      c:\Program Files\java\jdk1.5.0_06"

      ;This points to the bin directory of the jdk.
      java.home = "c:\Program Files\java\jdk1.5.0_06\bin"

      ;This must point to the Java Virtual Machine (jvm.dll) file
      java.library = "c:\Program Files\java\jdk1.5.0_06\jre\lib\bin\server\jvm.dll"

        In the first post you wrote that you tried to integrate the java extension of PHP 5.1.2 with PHP 5.0.2. That may be a problem. I'd suggest to download and install the extension that matches your version here .

        Thomas

          Thank you Thomas. I will try your suggestion.
          Paul

            Thomas
            Good news. I was able to start Apache OK ,so at this point it looks like java has a chance of running OK. It will probably take me a day to check this out. I will post to let you know of the results.
            Thank you for the great suggestion!
            Paul

              You can check that the extension has been loaded with a little phpinfo script. The output should contain a java extension section. A first step to see if the extension has been loaded with correct settings.

              Thomas

                Thomas.
                I successfully ran the phpinfo script, and indeed do have a java section!!
                It looks like you were exactly correct on the version problem.
                Thanks again. I will do a complete test tomorrow and let you know the results.
                Paul

                  Thomas,
                  After yesterday's success, I thought I was into clear sailing. But, I am unable to execute the java part of a simple program.
                  java.class.path ="c:\javaclasses ; c:\php5\php_jar" with my helloapp.java and helloapp.class located in the c:\javaclasses.
                  My php file : helloapp.php is located in c:\program Files\apache\apache2\htdocs
                  The helloapp class program contains the main and inside of that system.out.print statement of "helloworld". My php file is a one liner: exec("java Helloapp"}; (This statement was enclosed in <? php and ?> .
                  php runs fine, but it is the embedded java that doesn't work. Am I on the right track?

                    Ok,

                    you don't need the exec line. It's more like java being accessible directly through PHP.

                    The manual contains some simple examples.

                    Thomas

                      Sorry, I don't understand how to run example 1. I thought one has to first compile a java source program creating a .class file from a .java source. Then one would run the php program which contains a reference to the .class file. (By the way, I tried the Example 1 called in the Apache htdocs file. System locked up!)
                      Paul

                        How does the java section look like in the phpinfo() output ?

                          Here is the info in the java section of phpinfo:
                          java
                          Directive Local Value Master Value

                          java.class.path
                          (local value) c:\php5\php_java.jar;c:\javaclasses
                          (master value) c:\php5\php_java.jar;c:\javaclasses

                          java.home
                          (local value)c:\Program Files\java\jdk1.5.0_06\bin
                          (master value)c:\Program Files\java\jdk1.5.0_06\bin

                          java.library
                          (local value)c:\Program
                          Files\java\jdk1.5.0_06\jre\lib\bin\server\jvm.dll
                          (master value)c:\Program
                          Files\java\jdk1.5.0_06\jre\lib\bin\server\jvm.dll

                          java.library.path
                          (local value) c:\php5\ext\
                          (master value)c:\php5\ext\

                          Hope you could read this OK
                          Paul

                            Ok,

                            I think the java_home path is wrong.

                            Copy the php_java.jar to the ext folder and then try the following settings:

                            java.class.path="C:\php5\ext\php_java.jar;C:\javaclasses;C:\Program Files\java\jdk1.5.0_06\jre\lib;C:\Program Files\java\jdk1.5.0_06"
                            java.home="C:\Program Files\java\jdk1.5.0_06"
                            java.library="C:\Program Files\java\jdk1.5.0_06\jre\bin\server\jvm.dll"
                            java.library.path="C:\php5\ext;C:\Program Files\jdk1.5.0_06\jre\lib"

                            I'm not sure if those settings are completely correct. Check the paths. I checked my jdk 1.5.0_06 installation and the jvm.dll is in ...\jre\bin\server and not in ..\jre\lib\bin\server.

                            An alternative is the PHP/Java bridge. I compiled and successfully used it on a linux box but there's a binary package available that contains the windows files, too. Those file are packaged in the .war file that comes with the zip package.

                            Thomas

                              Thomas,
                              I implemented all of your file changes, and still get no response from java.
                              I looked at the Apache error log for the last time I tried to connect. It read something like:
                              "java.lang.noClassDefFoundError: javaprog."

                              javaprog is the .class file that contains the compiled java code. Perhaps this is a clue.
                              Thanks again for your patience and help.
                              Paul

                                That means that java couldn't find your class.

                                What about this example (taken from the manual) ?

                                <?php
                                // get instance of Java class java.lang.System in PHP
                                $system = new Java('java.lang.System');
                                
                                // demonstrate property access
                                echo 'Java version=' . $system->getProperty('java.version') . '<br />';
                                echo 'Java vendor=' . $system->getProperty('java.vendor') . '<br />';
                                echo 'OS=' . $system->getProperty('os.name') . ' ' .
                                             $system->getProperty('os.version') . ' on ' .
                                             $system->getProperty('os.arch') . ' <br />';
                                
                                // java.util.Date example
                                $formatter = new Java('java.text.SimpleDateFormat',
                                                     "EEEE, MMMM dd, yyyy 'at' h:mm:ss a zzzz");
                                
                                echo $formatter->format(new Java('java.util.Date'));
                                ?> 
                                

                                Execute this script and check if it prints anything. Check the error log if it contains any error.

                                Please post the source file of your java example as an attachment.

                                  Thomas,
                                  I placed your test php file(Thomas.php) in c:\Program Files\Apache Group\Apache2\htdocs. (I think that this is where it should be placed. Correct??)
                                  When I went to the browser and went to http://localhost/thomas.php I get a pop up message box saying: "Apache HTTP server has encountered a problem." I looked at the error report and it was as follows: "szAppName:Apache.exe szAppVer 2.0.52.0"
                                  The Apache error log didn't show anything unusual. (something about aquiring the start mutex).
                                  I will send another message with my test program which you asked for.

                                  To be sure I understand, I put all .php files that I wish to post in the htdocs file. I put all .class files associated with these .php files in c:\javaclasses which is on the java.class.path.
                                  Is this correct?
                                  (These .class files were created by separately compiling .java files.)
                                  In the case of Thomas.php there is no associated .java file so there is no compiling to be done. Correct?
                                  Thanks again for sticking with this.
                                  Paul

                                    This is a second message, please read the first one that I wrote a few minutes ago.
                                    Here is the test code that I have been using.

                                    <?php
                                    echo "Hello World!" ;
                                    $output = array();
                                    $return_var = 0;
                                    exec("java javaprog", $output, $return_var);
                                    $output_str = join($output, "\n");

                                    echo "<pre>The output was:\n$output_str\n\n";
                                    echo "The return value was $return_var</pre>";
                                    ?>

                                    // Here is javaprog.java

                                    public class javaprog
                                    {
                                    public static void main(String[] args)
                                    {
                                    System.out.println("Printed by Java program");
                                    System.exit(8) ;
                                    }
                                    }

                                      The error message means that apache crashed with the test script I posted. That's a bigger problem meaning that for some reason the java extension is instable.

                                      Your script executes java externally with the exec function. You don't need the java extension for that. The java extension enables PHP to access java classes in a PHP like style.

                                      Please give me more info about your setup (apache version, php version, MySQL version, ....).

                                      I'll try to reproduce the problem.

                                      Thomas

                                        I hope this helps:
                                        System:
                                        MS Windows XP Media Center Edition Version 2002 Service Pack 2
                                        IE 6.0
                                        AMD Athlon Prcoessor 3700+

                                        Java version jdk1.5.0_06
                                        Apache Version 2.0.52
                                        PHP Version 5.0.2
                                        MySQL Server 5.0
                                        PECL (java pecl for PHP) 5.0.2
                                        I am still quite confused.
                                        Question 1 My test program required that I off line compile the .java file. Then The system should be able to locate the corresponding .class file. Is this correct? You are saying that doing things this way does not require adding the java extension.? If this is true is it sufficient to store the .class file in java.class.path ? If the java extension were working, php would automatically compile the .java file??

                                        Question 2 Your test program calls up some java classes. These are part of the java.lang,system package which are usually loaded automatically in java. Therefore the java extension seems to be able to find these classes. Correct? I there were any external new classes these would have had to be converted to .class files ?

                                        Comment: Due to my unfamiliarity, I have a feeling that part of the problem here is my misunderstanding of what is going on. (So called "cockpit problems")
                                        Paul
                                        Paul