php-java-bridge

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
linuxuser
Forum Newbie
Posts: 3
Joined: Sat Jun 10, 2006 8:52 am

php-java-bridge

Post 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]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I hate to sound condescending but did you restart Apache?
ptobra
Forum Newbie
Posts: 11
Joined: Mon Jul 24, 2006 11:43 pm

Few Other Examples.

Post 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]
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

Without reading any of the docu's for PHP-Java, wouldn't Java::method() static calls work?
ptobra
Forum Newbie
Posts: 11
Joined: Mon Jul 24, 2006 11:43 pm

Still No Solution

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