PHP AND JAVA

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
fitchic77
Forum Commoner
Posts: 51
Joined: Thu Jul 20, 2006 11:57 pm

PHP AND JAVA

Post 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]
Last edited by fitchic77 on Sat Oct 16, 2010 11:30 am, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
fitchic77
Forum Commoner
Posts: 51
Joined: Thu Jul 20, 2006 11:57 pm

Post 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.
Last edited by fitchic77 on Sat Oct 16, 2010 11:30 am, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Did you restart the web server?

Code: Select all

$foo = new Foo();
makes

Code: Select all

$foo = new Foo();
fitchic77
Forum Commoner
Posts: 51
Joined: Thu Jul 20, 2006 11:57 pm

Post 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!!
Last edited by fitchic77 on Sat Oct 16, 2010 11:30 am, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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)?
fitchic77
Forum Commoner
Posts: 51
Joined: Thu Jul 20, 2006 11:57 pm

Post by fitchic77 »

I have read mostly everything but the javabridge stuff. I wasn't sure what it is?
Last edited by fitchic77 on Sat Oct 16, 2010 11:27 am, edited 1 time in total.
User avatar
dibyendrah
Forum Contributor
Posts: 491
Joined: Wed Oct 19, 2005 5:14 am
Location: Nepal
Contact:

Post 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
Post Reply