Page 1 of 1

php-java-bridge

Posted: Wed Jun 14, 2006 7:29 am
by linuxuser
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 am intergrating php with java.

Fedora Core 3 
php 5.1.4 
http 2.0.52-3 
java jdk 1.5.0_07 

I have compiled php-java-bridge-3.1 with java support without errors,

php.ini file has the following entry 

extension = java.so 
[Java] 


I am following the steps given in http://php-java-bridge.sourceforge.net/INSTALL

The following command from the console gives "java running"
echo '<?php phpinfo() ?>' | php | fgrep java

But

wget -olog -O-  http://localhost/phpinfo.php|fgrep java

does not give "java running" or does not show the java support.

In the browser 
http://localhost/test.php

Code: Select all

<?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'));
?>
gives the following error.

Fatal error: Class 'Java' not found in /var/www/html/test.php on line 3


Any dea?


Note: I have also tried with php-java-bridge-3.0.8.3, java j2sdk 1.4.2_12, php 4.3.9.


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 Jun 14, 2006 4:38 pm
by feyd
I hate to sound condescending but did you restart Apache?

Few Other Examples.

Posted: Mon Jul 24, 2006 11:54 pm
by ptobra
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 successfully integrated java support in php. And the sample program are running well.
Sample program 1:

Code: Select all

<?php

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

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

?>

Sample Program 2

Code: Select all

<? 
$system = new Java("java.lang.System");
echo "<P>Java version = " . $system->getProperty("java.version") . "<br>";
echo "Java vendor = " . $system->getProperty("java.vendor") . "</p>"; 
?>



my php.ini looks like

Code: Select all

extension=php_java.dll;

[Java]
java.class.path="C:\php\extensions\php_java.jar;"
java.home="c:\j2sdk1.4.2_06\bin"
java.library= "C:\j2sdk1.4.2_06\jre\bin\client\jvm.dll"
java.library.path="C:\php\extensions"

But I want to have more practice regarding how the classes can be accessed in php.
How to instantiate a static class and implement an interface.

Can we implement multithreading using the java classes in php. :roll: :roll: 8O


i need serious 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]
[color=darkgreen][b]feyd[/b] | Did this post need to be entirely bolded?[/color]

Posted: Tue Jul 25, 2006 3:14 am
by Jenk
Without reading any of the docu's for PHP-Java, wouldn't Java::method() static calls work?

Still No Solution

Posted: Tue Jul 25, 2006 3:54 am
by ptobra
i am sorry but that doesnt work... or is it i havent understood what you have written.
Could you be more precise with an example showing how to implement an interface in php and call that method.

:oops: