Integrating Java with PHP without recompiling

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
juher
Forum Newbie
Posts: 2
Joined: Wed Oct 27, 2004 4:07 pm

Integrating Java with PHP without recompiling

Post by juher »

I am currently in the process of migrating an application from windows to linux.
My boss wrote the app originally and uses a java api written by some one else. It only works becuase the windows version of php he has has support for running java inside the cole like so:

Code: Select all

<?php
  $myObject = new Java("the.class.we.want.to.run");
  $myObject->doParse($_GET['var1'], $_GET['var2']);

  if($myObject->isVerified()) 
  {
      do_some_stuff();
   }

?>
However, he also insists on going strictly RedHat Network all they way on the server. Becuase RHN's PHP package does not have java compiled in, it doesnt work.

Is there anyway to run this java app without compiling my own PHP?

thanks
j
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

Its really not that hard to compile PHP from the source code and it seems the easiest way to solve your problem. There are plenty of tutorials on how to do it, and there is always help here. To make things even easier for you all you need to do is run phpinfo() and get the configure line from the first table of information and then copy that to use on the source code and add on the java line to that. So you can just:

1)Download source.
2)Untar the code
3)./configure <data here>
4)make
5)make install clean

Could have had it done by the time you waited for this reply :P
juher
Forum Newbie
Posts: 2
Joined: Wed Oct 27, 2004 4:07 pm

um.. thanks

Post by juher »

I would rather compile it from source. But I am a temporary employee and I'm the only one who has idea how to do that.

I was wondering if there was a workaround so, when I leave, my boss could use rhn to update php like everything else.

Thanks though.

J
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

Weite a command line interface and use exec() like:

exec('java /path/to/my/program isVerified');
Post Reply