Connecting Tech Pros Worldwide Forums | Help | Site Map

PHP5 Java Bridge Configuration

Steven M. Scotten
Guest
 
Posts: n/a
#1: Jul 17 '05
Hi--

I seem to have the PHP Java Bridge (2.0.5 built from tarball) working with
PHP 5.0.3 (also built from tarball) on my Fedora Core 1 server with Apache
2.0.50 and I'm pretty excited about it all. There are a couple of
configuration issues I've run into that are perplexing me.

First, I can't seem to change the classpath. I've added:

[java]
java.class.path="/path/here"

to the php.ini file, just as indicated in setup documentation, phpinfo()
still reports only JavaBridge.jar in the classpath in the java section.

Without being able to add to the classpath, I can't access the Java objects
that I've built, so you can see how this could be a problem. =^)

Is there anyone that's set up the Java Bridge with PHP5 and gotten it
working? Obviously I'm tinkering in the wrong places.

It occurs to me that maybe the bridge doesn't work at all with .class files
and that in order to use these I'll need to package them in .jar files.
That's just an off-the-wall theory.

I'm a little disappointed in the bridge, although very excited about the
potential. PHP advocates have been talking about "Native Java Support" in
PHP since 2001 and even PHP5 requires some not-insignificant jumping-through
of hoops to add Java-PHP integration. Or is there something I'm totally
missing?

Thanks,


Steve


jost2345@yahoo.de
Guest
 
Posts: n/a
#2: Jul 17 '05

re: PHP5 Java Bridge Configuration


Hi,
[color=blue]
> I've added: java.class.path="/path/here"
> to the php.ini file, just as indicated in
> setup documentation[/color]

In which setup documentation have you found this? According to the
README it is java.classpath. That aside, you're right, the
documentation is currently in a horrible state, it's just that I don't
have enough time to work on it at the moment.

[color=blue]
> that I've built, so you can see how this could be
> a problem. =^)[/color]

The recommended method is to create a .jar file and store it in
/usr/share/java or in %JAVA_HOME%\jre\lib\ext (on windows) for
example, please see the INSTALL and README document. -- BTW: Why do
you want to load individual class files?


Regards,
Jost Boekemeier
Steven M. Scotten
Guest
 
Posts: n/a
#3: Jul 17 '05

re: PHP5 Java Bridge Configuration


Hi, and thanks for responding

On 4/2/05 1:37 AM, in article
c7d6f247.0504020037.575d4755@posting.google.com, "jost2345@yahoo.de"
<jost2345@yahoo.de> wrote:
[color=blue]
> In which setup documentation have you found this? According to the
> README it is java.classpath. That aside, you're right, the
> documentation is currently in a horrible state, it's just that I don't
> have enough time to work on it at the moment.[/color]

Arrgh. It looks like I was looking at the docs for the default Java Bridge
that comes with PHP4, not yours. Someone slap me.
[color=blue]
> The recommended method is to create a .jar file and store it in
> /usr/share/java or in %JAVA_HOME%\jre\lib\ext (on windows) for
> example, please see the INSTALL and README document. -- BTW: Why do
> you want to load individual class files?[/color]

The only reason being that I'm doing development and testing and I want to
be able to edit and swap classes out with emacs and javac. I'd like to add
to the classpath because I have a group of files I'm working on that I want
to keep in their own place. I guess the jarfile is how I keep everything in
one place though?

Thanks,


Steve

Steven M. Scotten
Guest
 
Posts: n/a
#4: Jul 17 '05

re: PHP5 Java Bridge Configuration


On 4/2/05 1:37 AM, in article
c7d6f247.0504020037.575d4755@posting.google.com, "jost2345@yahoo.de"
<jost2345@yahoo.de> wrote:
[color=blue]
> The recommended method is to create a .jar file and store it in
> /usr/share/java or in %JAVA_HOME%\jre\lib\ext (on windows) for
> example, please see the INSTALL and README document. -- BTW: Why do
> you want to load individual class files?
>[/color]


Does this mean that putting class files into /usr/share/java is not expected
to work? Judging by the "Uncaught thrown" error that I'm getting,
/usr/share/java is NOT in the classpath, or else .jar files are recognized
and .class files are not.

Also, classpath is reported only as

classpath=/usr/local/lib/php/extensions/no-debug-non-zts-20041030/JavaBridge
..jar

By phpinfo, so I'm clearly not doing something right.

Arrgh.


Steve

jost2345@yahoo.de
Guest
 
Posts: n/a
#5: Jul 17 '05

re: PHP5 Java Bridge Configuration


> Does this mean that putting class files into /usr/share/java is not expected[color=blue]
> to work?[/color]

Exactly. /usr/share/java is the global repository for java archives.
Please see http://www.jpackage.org/ for details. jpackage is part of
the desktop java project supported by RedHat. -- It's really a shame
that OS projects have to correct problems that Sun cannot or is not
willing to change since more than 5 years. Please help us to stop
this classpath nonsense which causes that multiple versions of classes
are scattered all over the directory structure (belonging to different
users, have different permissions etc, etc...).

[color=blue]
> Also, classpath is reported only as
> classpath=/usr/local/lib/php/extensions/no-debug-non-zts-20041030/JavaBridge
> .jar[/color]

Please don't forget the double-quotes, please see
http://php-java-bridge.sourceforge.net/#ini-options for details.


Regards,
Jost Boekemeier
Steven M. Scotten
Guest
 
Posts: n/a
#6: Jul 17 '05

re: PHP5 Java Bridge Configuration


On 4/16/05 7:29 AM, in article
c7d6f247.0504160629.7b48fa19@posting.google.com, "jost2345@yahoo.de"
<jost2345@yahoo.de> wrote:
[color=blue]
> Exactly. /usr/share/java is the global repository for java archives.
> Please see http://www.jpackage.org/ for details. jpackage is part of
> the desktop java project supported by RedHat. -- It's really a shame
> that OS projects have to correct problems that Sun cannot or is not
> willing to change since more than 5 years. Please help us to stop
> this classpath nonsense which causes that multiple versions of classes
> are scattered all over the directory structure (belonging to different
> users, have different permissions etc, etc...).[/color]

Okaaaay.... What can I do to "stop the nonsense"? I'm not certain what
you're suggesting.

[color=blue]
> Please don't forget the double-quotes, please see
> http://php-java-bridge.sourceforge.net/#ini-options for details.[/color]

OK, that solved my problem, and I feel kinda foolish. Thanks!

Is there a PHP/Java Bridge users forum somewhere? I suspect that I'm going
to have a lot more questions and fun with this as I go along. Neither
comp.lang.php nor any of the java newsgroups seem like the ideal place to
discuss.

Thanks,


Steve

jost2345@yahoo.de
Guest
 
Posts: n/a
#7: Jul 17 '05

re: PHP5 Java Bridge Configuration


> > this classpath nonsense which causes that multiple versions of classes[color=blue][color=green]
> > are scattered all over the directory structure (belonging to different
> > users, have different permissions etc, etc...).[/color]
>
> Okaaaay.... What can I do to "stop the nonsense"? I'm not certain what
> you're suggesting.[/color]

Please create a .jar file from your classes and store it as
/usr/share/java/myProject/myLibrary-version.jar or as `php-config
--extension-dir`/lib/myProject/myLibrary-version.jar. After that you
can reference your library with:

java_set_library_path("myProject/myLibrary-version.jar;<other
libraries...>");

at run-time.
(In versions prior to 2.0.6 it was necessary to use the full path i.e.
java_set_library_path("/usr/share/myProject/myLibrary-version.jar");)

That way you can specify exactly which library version you want and
you don't have to re-start the bridge if you want to add additional
libraries.

[color=blue][color=green]
> > Please don't forget the double-quotes, please see
> > http://php-java-bridge.sourceforge.net/#ini-options for details.[/color]
>
> OK, that solved my problem, and I feel kinda foolish. Thanks![/color]

Yeah. The documentation is still evolving. Sorry for that.

[color=blue]
> Is there a PHP/Java Bridge users forum somewhere?[/color]

Either http://sourceforge.net/forum/?group_id=117793 or our mailing
list:
-> php-java-bridge-users@lists.sourceforge.net


To subscribe:
-> http://lists.sourceforge.net/lists/l...a-bridge-users

Archive:
-> http://sourceforge.net/mailarchive/f...a-bridge-users


Regards,
Jost Boekemeier
Zou_Benjamin
Guest
 
Posts: n/a
#8: Aug 31 '05

re: PHP5 Java Bridge Configuration


> bumeshraiwrote:
[color=blue]
> when I run a php page for writting out a file, I log the following[/color]
error:[color=blue]
>
> java.lang.ClassNotFoundException: Class[/color]
java.io.FileOutputStream('workbook.xls') not found[color=blue]
> at[/color]
php.java.bridge.DynamicClassLoader.loadClass(Dynam icClassLoader.java:358)[color=blue]
> at[/color]
php.java.bridge.JavaBridgeClassLoader.forName(Java BridgeClassLoader.java:58)[color=blue]
> at php.java.bridge.JavaBridge.CreateObject(JavaBridge .java:450)
> at php.java.bridge.Request.handleRequests(Request.jav a:197)
> at php.java.bridge.JavaBridge.run(JavaBridge.java:142 )
> at php.java.bridge.ThreadPool$Delegate.run(ThreadPool .java:20)
>
>[/color]
Did you require the *.jar that contians the class you were using?

peter
Guest
 
Posts: n/a
#9: Sep 5 '05

re: PHP5 Java Bridge Configuration


Hello!
[color=blue][color=green]
> > java.lang.ClassNotFoundException: Class[/color]
> java.io.FileOutputStream('workbook.xls') not found
> Did you require the *.jar that contians the class you were using?[/color]

I do not think that a class called
`java.io.FileOutputStream('workbook.xls')' exists, even though it is a
valid class name. 8)

You probably want something like java("java.io.FileOutputStream",
'workbook.xls'); instead of
new java("java.io.FileOutputStream('workbook.xls')");

:)

Newbie
 
Join Date: May 2006
Posts: 1
#10: May 5 '06

re: PHP5 Java Bridge Configuration


Hi Steven,
The problem is with class path.
u have to set class path as

java.classpath=/path/java/files

I'm sure that it will work for u.I faced same kind of problem and It was working fine for me

regards,
Pawan




Quote:

Originally Posted by Steven M. Scotten

Hi--

I seem to have the PHP Java Bridge (2.0.5 built from tarball) working with
PHP 5.0.3 (also built from tarball) on my Fedora Core 1 server with Apache
2.0.50 and I'm pretty excited about it all. There are a couple of
configuration issues I've run into that are perplexing me.

First, I can't seem to change the classpath. I've added:

[java]
java.class.path="/path/here"

to the php.ini file, just as indicated in setup documentation, phpinfo()
still reports only JavaBridge.jar in the classpath in the java section.

Without being able to add to the classpath, I can't access the Java objects
that I've built, so you can see how this could be a problem. =^)

Is there anyone that's set up the Java Bridge with PHP5 and gotten it
working? Obviously I'm tinkering in the wrong places.

It occurs to me that maybe the bridge doesn't work at all with .class files
and that in order to use these I'll need to package them in .jar files.
That's just an off-the-wall theory.

I'm a little disappointed in the bridge, although very excited about the
potential. PHP advocates have been talking about "Native Java Support" in
PHP since 2001 and even PHP5 requires some not-insignificant jumping-through
of hoops to add Java-PHP integration. Or is there something I'm totally
missing?

Thanks,


Steve

Closed Thread