Possible Duplicate:
Execute external program from Java
Is it possible to Run a php script from a java class. My project is a struts2 frame work web application. Its purely a java webapp We use a php script to run some daily cron jobs. It was written in php by an ex-employee. Is there a way to run the php script from the javaclass?
Since you’re essentially running a command line script, you could use
Runtime.getRuntime().exec. Here’s a page with a plethora of examples: http://www.rgagnon.com/javadetails/java-0014.html.If the PHP script is externalized as a web page, you could use Java’s
URLConnectionto call the page so it runs. Documentation: http://download.oracle.com/javase/tutorial/networking/urls/readingWriting.html