Caucho Forums  

This forum is permanently closed because of spam. For free community support, please visit Google Groups:


Go Back   Caucho Forums > Quercus

Reply
 
Thread Tools Display Modes
  #1  
Old 12-12-2011, 12:16 AM
bentheboffin bentheboffin is offline
Junior Member
 
Join Date: Dec 2011
Posts: 1
Default Using PHP class in Java

I need to use a class created in PHP in Java. I figure this should be straightforward using Quercus but can't work out out how to do it. (All the documentation & examples I've found are the other way around - ie using Java in PHP)

I have seen references to Quercus creating .java files from the php code in a /work/ folder. I think this would give me what I need as I could then incorporate these files into my Java project, but I can't seem to find these files anywhere (despite searching my entire computer by modified date!).

Any help would be much appreciated (including telling me if this is actually impossible and therefore saving me from wasting time trying to figure it out!).
Reply With Quote
  #2  
Old 03-01-2012, 03:34 AM
adam adam is offline
Member
 
Join Date: Oct 2009
Posts: 31
Default

A few times I have needed php functions in Java. I have not found a direct way to do this, but something I have done in the past is call the php code from java/jsp/servlet and then just capture the output.

Since it typically happens in the same app server, there is very little overhead. Something to this effect


Code:
ArrayList<String> phpOut= new ArrayList<String>();
URL u = new URL("url_to_php");
URLConnection uc = u.openConnection();
uc.setDoOutput(true);
BufferedReader in = new BufferedReader(new InputStreamReader(uc.getInputStream()));
String temp = in.readLine();
while (temp != null) {
      phpOut.add(temp);
      temp = in.readLine();
}
// ... process contents of phpOut array
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:11 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.