I have the Java JVM installes on my server.
I uncommented
extension=php_j ava.dll
in php.ini
I uncommented and proerpyl filled out the [java] section in php.ini:
[Java]
java.class.path ="C:\InstantRai ls\php\extensio ns\php_java.jar ;C:\JavaSources \MyStuff"
java.home = "C:\Program Files\Java\jdk1 .5.0_10;C:\Prog ram Files\Java\jre1 .5.0_10\lib"
java.library = "C:\Program Files\Java\jdk1 .5.0_10\jre\bin \server\jvm.dll "
java.library.pa th = "C:\InstantRail s\php\extension s\;C:\Program Files\Java\jdk1 .5.0_10\jre\lib "
I created a little php file to test it all out:
<?php
$system = new Java("java.lang .System");
echo 'Java version installed = ' . $system->getProperty('j ava.version') . "<br />";
echo 'Java vendor = ' . $system->getProperty('j ava.vendor') . "<br />";
echo 'Running on server = ' . $system->getProperty('o s.name') . "<br />";
$des = new java("DES","xra y");
echo $des . "<br />";
$x="hello";
echo $x . ' = ' . $des->encrypt($x);
?>
Which outputs as:
Java version installed = 1.5.0_10
Java vendor = Sun Microsystems Inc.
Running on server = Windows XP
Object
hello =
Note that I have a class file C:\JavaSources\ MyStuff\DES.cla ss with an encrypt(String) function. Everything works fine, even when I echo out $des it shows as Object.
However, my last line does not output the encrypt function. Can anyone tell me why?
Also, if I go to run the php script a subsequent time, I get:
Fatal error: Unable to create Java Virtual Machine in c:\instantrails \www\javafromph p.php on line 2
unless I either reboot the computer or restart my apache web server under which php is running. Anyone ever call a java class from php? -R. Vince