Page 1 of 1

PHP AND JAVA

Posted: Wed Aug 16, 2006 5:23 pm
by fitchic77
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I have tried to install php java components, but no luck  I have tried both j2sdk1.4.2_12 as well as jdk1.1.8 and no luck!

php.ini

Code: Select all

[Java]
java.library.path = "C:\php\ext"
java.class.path = "C:\php\ext\php_java.jar"
java.home = "C:\jdk1.1.8\bin"
java.library = "C:\j2sdk1.4.2_12\jre\bin\server\jvm.dll"
The "java.library" entry in my php.ini file bombs my apache server.


javatest.php

Code: Select all

<?php 
      $system_inst = new Java('java.lang.System');
      // Test PHP's ability to get a property from a Java class 
      echo "The version of Java running is" . $system_inst->getProperty("java.version") ;
?> 

<?php

$systemInfo = new Java("java.lang.System");

print "Total seconds since January 1, 1970: 
".$systemInfo->currentTimeMillis();

?>


If anyone has this working I'd appreciate any help.



feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Wed Aug 16, 2006 5:31 pm
by feyd
Are you sure PHP has the Java components loaded? Run phpinfo() and look for a Java section, compare your settings with its.

I'm getting pretty tired of editing your posts to add code highlighting.

Posted: Wed Aug 16, 2006 5:40 pm
by fitchic77
Sorry about the tags!! I guess I'm supposed to put php tags like this

Code: Select all

?? I was reading about it and was having trouble figuring it out....

I don't want to stress you out especially when you are helping me!!! =) ...so my sincere apologies...

Regarding phpinfo(), I don't see any java anything listed.

In my php.ini file, I have enabled the extension=php_java.dll which is in my PHP extensions folder (c:\php\ext) along with the rest.

What do I have to do to get java installed. From all the reading it was:

1) extension=php_java.dll in the php.ini
2) Installed java sdk
3) enter in php.ini

[Java]
java.library.path = "C:\php\ext"
java.class.path = "C:\php\ext\php_java.jar"
java.home = "C:\jdk1.1.8\bin"
java.library = "C:\j2sdk1.4.2_12\jre\bin\server\jvm.dll" 


What am I missing then.

Posted: Wed Aug 16, 2006 5:50 pm
by feyd
Did you restart the web server?

Code: Select all

$foo = new Foo();
makes

Code: Select all

$foo = new Foo();

Posted: Wed Aug 16, 2006 5:51 pm
by fitchic77
dohhh...I didn't scroll down:

This is the info from phpinfo();

java
Directive Local Value Master Value
java.class.path C:\php\ext\php_java.jar C:\php\ext\php_java.jar
java.home C:\j2sdk1.4.2_12\jre\bin C:\j2sdk1.4.2_12\jre\bin
java.library c:\php\ext;C:\j2sdk1.4.2_12\jre\bin\server\jvm.dll c:\php\ext;C:\j2sdk1.4.2_12\jre\bin\server\jvm.dll
java.library.path C:\php\ext C:\php\ext


And this is the error from my javatest.php

Fatal error: java() [<a href='function.java'>function.java</a>]: Unable to load Java Library c:\php\ext;C:\j2sdk1.4.2_12\jre\bin\server\jvm.dll, error: The specified module could not be found. in C:\Program Files\Apache Group\Apache2\htdocs\test\sterling\javatest.php on line 2

I've also tried C:\j2sdk1.4.2_12\jre\bin\client\jvm.dll AND no go...


Stumped!!

Posted: Wed Aug 16, 2006 6:14 pm
by feyd
hmm, I don't work with Java in PHP, so bare with me here.

Did you go through all the user comments on http://php.net/ref.java?
Did you try the oft linked Java Bridge (links are all over the user comments)?

Posted: Wed Aug 16, 2006 6:18 pm
by fitchic77
I have read mostly everything but the javabridge stuff. I wasn't sure what it is?

Posted: Thu Aug 17, 2006 12:05 am
by dibyendrah
Hello dear,
I have hear about php-java-bridge but not impleted yet. Hope you'll find useful in this project http://php-java-bridge.sourceforge.net/

Cheers,
Dibyendra