This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
I want to invoke perl exe from java.It does not seem to work with Runtime.exe like the other exes.Any clue? The piece of code is Process stopRPSproc = Runtime.getRuntime().exec("perl.exe"); the call just comes out
First, try using the complete (absolute) path to the perl.exe file - e.g. C:\programs\perl\perl.exe or whatever. It's possible to use a relative path also, but you need to know what directory java is executing from, and where perl.exe is relative to that; if you have any problems, it's easiest to use the absolute path. If this does not work, try using the Process method getErrorStream(), read from the InputStream it gives you, and print the results to your screen or a file somewhere. Chances are good there's an error message here which will give you further clues. Good luck.
Look at the java.lang.Process API - in particular the getErrorStream getInputStream getOutputStream methods. These methods let you read and write the standard in, out and err streams that Perl uses If your Perl program writes output to the screen you must read it or the Perl program may hang. Separate threads for reading the out and err are a good idea. Bill
Joined: Sep 14, 2003
Hi Brogden, Shall I use perl language in jsp tags instead of java. Pls explain with example
Author and all-around good cowpoke
Joined: Mar 22, 2000
If you start Perl, it is going to expect input of a Perl program from somewhere - usually from a file - plus possibly command line parameters. The only control you would have from JSP would be in setting up the command line to Perl. Bill
On a windows 2000 you should do in the following way to invoke external process (doesn't matter perl or other, BTW, I had to invoke Perl scripts in our current script and this works great): String command = new String; command = "cmd.exe"; command = "/C"; command = "perl.exe"; Process proc = Runtime.getRuntime().exec(command);