|
From: <php...@li...> - 2009-09-07 11:59:15
|
> caught exceptionjava.io.IOException: Cannot run > program "php-cgi" > CreateProcess error=2, The system cannot find the file specified This error message means that php is not installed or php-cgi not in the path. Please install PHP. You can set the php.java.bridge.php_exec System.property to specify a custom php executable path, for example: java -Dphp.java.bridge.php_exec=/opt/PHP/bin/php-cgi If you have Apache/php or IIS/php running elsewhere, you can copy you php scripts there and use an urlConnection to execute them remotely, as shown in the example you have given. Otherwise please see the PhpScriptEngine documentation, it contains an example. Regards, Jost Boekemeier Regards, Jost Boekemeier 7. Sep 2009 12:02 nachm. schrieb am < php...@li...>: > > hi, Aplogies if you receive the same mail more than once! > > > I tried calling php fucntion from java file but I am getting below > exception. > > caught exceptionjava.io.IOException: Cannot run program "php-cgi": > CreateProcess error=2, The system cannot find the file specified. > > I tried running the java file by having JavaBridge.jar and php-script.jar > files in classpath.Though in my javafile I am calling the remote php script > actually my requirement is to call php functions from standalone java file(I > tried doing the sam but got the same error).Can any body give step by step > way of creating a standalone java file and calling the php script from it.I > also need what are the jar files you place in classpath and other supporting > files require to execute them properly. > > Please find java file and php files below. > > I am need to do this asap.Any help is highly appreciated. > > > java file > > ===================================================================================== > import javax.script.*; > import java.net.*; > import java.io.*; > class SampleTest { > public static void test(Integer month) throws Exception { > try{ > ScriptEngine e = new > ScriptEngineManager().getEngineByName("php-invocable"); > ByteArrayOutputStream out; > OutputStreamWriter writer; > e.getContext().setWriter(writer=new OutputStreamWriter(out=new > ByteArrayOutputStream())); > Object res=e.eval(new php.java.script.URLReader(new URL(" > http://localhost:8080/JavaBridge/eg.php"))); > System.out.println("Got here"); > ((Invocable)e).invokeFunction("writeName", new Object()); > //System.err.println(((Invocable)e).invokeFunction("writeName", > new Object())); > ((Closeable)e).close(); > System.err.println("PHP exit() code:" + String.valueOf(res)); > System.err.println("PHP output:" + String.valueOf(out)); > }catch(Exception e){ > System.out.println("caught > exception"+e.getLocalizedMessage()); > } > } > public static void main(String s[]) throws Exception { > test(new Integer(12)); > } > } > > ========================================================================================================= > Php File: > > ========================================================================================================= > <?php require_once("java/Java.inc"); > function writeName() > { > echo "Kai Jim Refsnes"; > } > ?> > > ========================================================================================================== > > Thanks, > Pavan. > ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ php-java-bridge-users mailing list php...@li... https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users |