Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

There used to be a PHP extension that could load Java libraries and call methods in them. That was for PHP 4.

Is there a way to do the same in PHP 5?

share|improve this question
add comment

3 Answers

up vote 1 down vote accepted

Doesn't look like there's a built-in way, even the support in php4 was experimental. Doesn't really make sense to start up a Java Virtual Machine on each request for php. You could always use the shell-escaping capabilities (backtick operator) if you have to do something in Java but if you want to make something scalable it needs to be its own Java service and accept SOAP/REST or however you want to talk to it from php.

share|improve this answer
 
You're right, it's not really reasonable. Unfortunately I have a third-party Java client library (or, alternatively, a .net version) I need to make a few calls to and I don't want to set up Tomcat or some other unmaintainable Java crap. I think, I'll go for the command line. –  AndreKR Dec 29 '10 at 14:32
add comment

If you need Java integration in PHP 5, there is the Zend Server Java bridge:

http://www.zend.com/en/products/server-ce/

and "PHP/Java Bridge":

http://php-java-bridge.sourceforge.net/pjb/

EDIT

If you don't like either of the above options, then consider using Quercus. This is a Java implementation of PHP, that makes it easy to reference Java from within PHP and vice-versa

share|improve this answer
2  
The first one is not PHP (but rather a kind of distribution with webserver, etc.) The second one is... well... a protocol to access a web service with PHP. I don't know why one would need software for that at all, you could just write it down using cURL. Completely useless. –  AndreKR Dec 28 '10 at 21:54
 
@AndreKR Wouldn't it be the same has having JYthon or any of the other JVM implementations of another language? –  johnny Sep 30 '13 at 13:45
add comment

You could use Quercus. It's a PHP 5 runtime written in Java you can install on top of a JavaEE application server.

http://www.caucho.com/products/quercus/

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.