Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2006

Tip: Looking for answers? Try searching our database.

How to interact with a Live java process from php?

Thread view: 
Sophia - 20 Jan 2006 00:25 GMT
Hi,

My question is pretty much what the title describes.  My situation is:
The essential task is to provide a service to web user.  This service
can only be accessed from a java program on the backend, and this
program, unfortunately, is a 24/7 live process.  My teammate is going
to write a php program to handle the front end request, so my question
is that, is it possible for such a  design to work? If it is, how?

Any help is greatly appreciated!

Sophia
IchBin - 20 Jan 2006 00:33 GMT
> Hi,
>
[quoted text clipped - 8 lines]
>
> Sophia

Have not done it but here some information. Google for PHP Java.

 http://us3.php.net/java
 http://php-java-bridge.sourceforge.net/
 http://www.phpbuilder.com/manual/ref.java.php
 http://www.onlamp.com/pub/a/php/2001/06/14/php_jav.html

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor,  Regular Guy (1952-)
Sophia - 20 Jan 2006 01:13 GMT
Thanks IchBin,
I understand that there are ways to initiate a java instance from php
program.  But I was talking about communicate to a running java
process.  Right now, what I can think of is the old way of socket
programming, that is, the java program and the php program send xml
request/reply to each other via unix sockets.  Any better ideas?
IchBin - 20 Jan 2006 03:37 GMT
> Thanks IchBin,
> I understand that there are ways to initiate a java instance from php
> program.  But I was talking about communicate to a running java
> process.  Right now, what I can think of is the old way of socket
> programming, that is, the java program and the php program send xml
> request/reply to each other via unix sockets.  Any better ideas?

Sorry, I am not to strong with PHP.

Signature

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor,  Regular Guy (1952-)

Gordon Beaton - 20 Jan 2006 07:56 GMT
> I understand that there are ways to initiate a java instance from
> php program. But I was talking about communicate to a running java
> process. Right now, what I can think of is the old way of socket
> programming, that is, the java program and the php program send xml
> request/reply to each other via unix sockets. Any better ideas?

"Old" sockets are a natural choice for communicating with an existing
process. This is especially the case when the two components are
written using different languages or technologies. If you want
alternatives, describe why sockets are not suitable.

/gordon

Signature

[  do not email me copies of your followups  ]
g o r d o n + n e w s @  b a l d e r 1 3 . s e

Sophia - 20 Jan 2006 20:59 GMT
Hi Gordon,

Sockets are actually one of the things i used most in my school
projects, you are right, they are good for communicating between
different processes/langs.  My doubt was that in socket programming,
the programmer pretty much handles everything above tcp/ip layer, in a
real project when reliability is essential, is it safer to use some
established frameworks?  Say in my project, if there are 100 users
hitting the php pages at the same time, thus 100 socket connection
requests to my Java or C++ program, what do I need to do to provide a
reliable service?

Sorry if my language is very vague, I am neither an experienced
programmer nor a native English speaker.
Sophia - 20 Jan 2006 20:59 GMT
Hi Gordon,

Sockets are actually one of the things i used most in my school
projects, you are right, they are good for communicating between
different processes/langs.  My doubt was that in socket programming,
the programmer pretty much handles everything above tcp/ip layer, in a
real project when reliability is essential, is it safer to use some
established frameworks?  Say in my project, if there are 100 users
hitting the php pages at the same time, thus 100 socket connection
requests to my Java or C++ program, what do I need to do to provide a
reliable service?

Sorry if my language is very vague, I am neither an experienced
programmer nor a native English speaker.
Dimitri Maziuk - 20 Jan 2006 17:11 GMT
Sophia sez:
> Thanks IchBin,
> I understand that there are ways to initiate a java instance from php
> program.  But I was talking about communicate to a running java
> process.  Right now, what I can think of is the old way of socket
> programming, that is, the java program and the php program send xml
> request/reply to each other via unix sockets.  Any better ideas?

Depending on what you need to do, sockets, named pipes (fifos),
a php module that talks rmi, php corba module. In the simple case
I'd probably dump xml and use a less bloated exchange format.

Dima
Signature

The most horrifying thing about Unix is that, no matter how many times you hit
yourself over the head with it, you never quite manage to lose consciousness.
It just goes on and on.                                  -- Patrick Sobalvarro

Sophia - 20 Jan 2006 21:02 GMT
Thanks Dima, I am curious that why you think <xml> is a bloated
exchange format.  To me, It looks like of the same class of pure txt
(with some descriptive tags).
Dimitri Maziuk - 21 Jan 2006 00:14 GMT
Sophia sez:
> Thanks Dima, I am curious that why you think <xml> is a bloated
> exchange format.  To me, It looks like of the same class of pure txt
> (with some descriptive tags).

Yeah, if you treat it like "text with a few descriptive tags",
it is that. OTOH, consider a table of numbers, say, ID, value,
error. Depending on how you structure your DTD and name the
tags, e.g.
<id>1</id><val>1.2</val><err>0.005</err>
this is 40 characters total, 10 characters of data per row:
75% overhead. Plus there should be a dtd lurking somewhere.

It really depends on your application, obviously.

Dima
Signature

Things seemed simpler before we kept computers.              -- IX, Revelation

peter - 22 Jan 2006 19:07 GMT
Hello!

> I understand that there are ways to initiate a java instance from php
> program.

It doesn't initiate a java instance. At least the php-java-bridge
communicates with the java server via plain html.

> I can think of is the old way of socket programming

Hmm, what about a servlet engine and then post the data to the servlet.
This should be trivial to implement

> program send xml
> request/reply to each other via unix sockets

Probably. But unix sockets are said to be much slower than pipes:
http://sourceforge.net/mailarchive/forum.php?thread_id=9464841&forum_id=42415

peter


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.