Mombu the Php Forum

Go Back   Mombu the Php Forum > Php > calling java within php setup?
User Name
Password
REGISTER NOW! Mark Forums Read




Reply Bookmark and Share
1 9th November 21:11
janet9k
External User
 
Posts: 1
Default calling java within php setup?



I'm trying to call java within php. I have JAVA JRE 1.6 installed. The php
I'm using is distributed by our partner so I couldn't configure it to use
JAVA.

I've modified the "php.ini" file to add the JRE path to it:

java.class.path="/usr/java/jre1.6.0_01"
java.home="/usr/java/jre1.6.0_01/bin"
java.library.path="/usr/java/jre1.6.0_01/lib"

Below is the java part:

<?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'));
?>
  Reply With Quote


 


2 9th November 21:11
stuttle
External User
 
Posts: 1
Default calling java within php setup?



Have you installed it? From the manual page for the Java extension...

"This » PECL extension is not bundled with PHP."

-Stut

--
http://stut.net/
  Reply With Quote
3 9th November 21:11
ceo
External User
 
Posts: 1
Default calling java within php setup?


Modifying php.ini doesn't get the Java extension installed.

They have to PECL install Java extension for it to work.
You'll know if they have done that by checking <?php phpinfo();?>
output. It either mentions Java, and it's installed; or it doesn't, and it's not.


You don't have that class to instantiate, because you don't have the
extension installed.

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?
  Reply With Quote
4 9th November 21:11
janet9k
External User
 
Posts: 1
Default calling java within php setup?


Hi Richard,

They didn't installed PECL. Is there a way to installed just PECL and not
overwrite their php configuration?

I noticed when I went to the PECL link I didn't see a PECL package download,
but I had to search for packages I wanted to install, what am I looking for?

Thanks!
  Reply With Quote
5 9th November 21:12
jochem
External User
 
Posts: 1
Default calling java within php setup?


Janet N schreef:

pecl is a wrapper/package manager for building/installing php extensions.
I believe you can install it by following the guidelines for installing pear:

http://pear.php.net/manual/en/installation.php

you get pecl when pear is installed - although you will need root access to install
it.

then again you don't need to install pecl to build the java extension as such,
although you'll need root access to actually place the extension in the 'right'
place.

to start with the source of the extension in question.
which is the following as far as I can tell:

http://cvs.php.net/viewvc.cgi/pecl/rpc/java

it looks like you have download it direct from cvs - doesn't seem to be available anywhere
else.

once you have the source, cd to the directory containing it and run the following commands

$> phpize
$> ./configure
$> make

with a bit of luck you'll then have a .so file that is your new extension,
now it a matter moving the .so to a suitable place (if you have root access, you
can run 'make install') and of editing php.ini to load the extension.

hth ... although if your anything like me it won't help until you've sworn at the
output of ./configure and/or make a thousand times ;-)

you might consider the advice on php.net to try using the SOAP extension to
access your java stuff that way instead.
  Reply With Quote
6 10th November 03:09
ceo
External User
 
Posts: 1
Default calling java within php setup?


If you don't have root, you probably can't move it to the suitable place.

Otherwise, any bozo could install and .so file into the PHP binary,
which could do anything at all to the PHP process, including hack all
kinds of nasty functions to, say, dump ALL incoming GET/POST data
whose variable name looks like "*cc*" or "*credit*" or "*card*" out to
some email address...

That said, if your host is a bit lax in security, you might be able to
use DL to LOAD your .so file into your script:
http://php.net/dl

Note that 'dl' is probably going away in PHP 6, last I heard.

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?
  Reply With Quote
7 12th November 04:26
janet9k
External User
 
Posts: 1
Default calling java within php setup?


I have root; I was able to compile php with java and working now. Thanks
all!
  Reply With Quote
Reply


Thread Tools
Display Modes


Some other forums that might be of your interest : Php 5 forum, Apache forum, Iis forum, Functions forum, Classes forum, Librarys forum, Bugs forum, Postgres forum, Mysql forum, Paradox forum, Ms sql forum, Configurations forum, Php.ini forum, Problems forum, Scripting forum, Css forum, General forums, Off-topic talk, Links, Extra forums, Php


Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666