0

I need to develop a web application using PHP and the Apache web server. The application should call an external Java-based application which is stored in the host computer and pass the user's input value to this application which will analyse it and do something. I have been reading articles about PHP/Java and it seems that the best solution is to integrate a PHP into a Java servlet environment such as PHP/JavaBridge. As I am not an expert on web development and pretty ignorant on PHP, can someone tell me if this is the best solution and if not, what other possible approaches should I use it? Thanks in advance!

Anto
  • 4,265
  • 14
  • 63
  • 113
  • What kind of application are you trying to call? Is it a command line application written in Java, a web-based Java application, an applet? These types of applications require different methods to call them. – jan.vdbergh Feb 04 '11 at 12:50
  • It's a standard stand-alone application, not web-based... – Anto Feb 04 '11 at 13:32

3 Answers3

1

You could do something like this:

$parameter1='your';
$parameter2='parameters';

$output = shell_exec("java whatever.jar $parameter1 $parameter2");

echo $output;

* Update *

I do agree with Jigar Joshi, though. I think a web service would be the best option here.

xil3
  • 16,305
  • 8
  • 63
  • 97
  • This is actually the answer to the question (thus the +1 vote). As starting the java runtime is quite expensive (for a web request) and results in a high latency, I do agree with the *Update* that Web services are a better answer to the problem. – extraneon Feb 04 '11 at 13:12
1

The application should call an external Java-based application which is stored in the host computer and pass the user's input value to this application which will analyse it and do something.

WebServices are perfectly suited here.

Also See

Community
  • 1
  • 1
jmj
  • 237,923
  • 42
  • 401
  • 438
0

You may explose your already existing java application api as web-services (jax-ws or jax-rs) and then use any application to call that. So you can write an web-wrapper around your java-webapp and then call it. First approach it better approach.

Neo
  • 31
  • 2