PHP 4 - Java integration on Win32, and examples

Posted: Sun 20/01/2002 12:01:00 PM

To integrate Java and PHP - Win32.

// php.ini

;Windows Extensions
;Note that MySQL and ODBC support is now built in, so no dll is needed for it.
extension=php_java.dll

[Java]
java.class.path =
"c:\php\extensions\php_java.jar;c:\apache2\htdocs\classes"
java.home = "c:\j2sdk1.4.2_01\bin"
java.library = "c:\j2sdk1.4.2_01\jre\bin\server\jvm.dll"
java.library.path = "c:\php\extensions"

// javainfo.php

<?php

$system_inst = new Java('java.lang.System'); 
echo "Java version is " .  $system_inst->getProperty("java.version"); 

?>

// c:\apache2\htdocs\classes\HelloWorld.java

public class HelloWorld
{
  String hw = "Hello World";

  public String getHelloWorld()
  {
    return hw;
  }
}

// helloworld.php

<?php

  $myObj = new Java("HelloWorld");

  // Display HelloWorld
  echo $myObj->getHelloWorld();

?>

Copyright © 2001-2007. Kang, S. Information Systems. University of Wollongong. Australia. All rights reserved.