Subject: how to invoke a Perl script from Java Program.

From: Chen Shapira <[email-masked]>
Date: Thu, 13 Jul 2000 17:10:23 +0200

> Below is an example how to invoke a Perl script from
> Java program. Take your attention that this program
> - sets the workDir directory.
> - invokes the Perl runtime through a .bat script.
> All the sources are supplied.
> 
> import java.io.*;
> 
> public class Test {
>    public static void main(String[] args) {
> 	String[] cmd = new String[3];
> 	cmd[0] = "command.com";
> 	cmd[1] = "/C";
> 	cmd[2] = "runPerl.bat";
> 	String[] param = {""};
> 	File workDir = new File("d:/perl");
> 	try { 
> 	   Process p = Runtime.getRuntime().exec(cmd, param, workDir); 
> 	   BufferedReader br = new BufferedReader(new
> InputStreamReader(p.getInputStream()));
> 	   String line;
> 	   while ((line = br.readLine()) != null) {
> 		System.out.println(line);
> 	   }
> 	   br.close();
> 	} catch(Exception ex) { System.out.println("Can not execute: " +
> ex.toString()); }
> 	   System.out.println("Done!");
> 	}
> }
> 
> REM runPerl.bat Source
> @echo off
> D:\Perl\perl D:\Perl\helloWorld.pl
> 
> ## helloWorld.pl Source
> print "Hello World!\n";

Anyone knows a better way to do that?

---

From: Shlomi Fish <[email-masked]>
Date: Fri, 14 Jul 2000 12:23:13 +0300 (IDT)

What's wrong with using "perl" as the first command or "d:\perl\perl",
etc.

Check that perl is properly installed on your system.

Regards,

	Shlomi Fish

----------------------------------------------------------------------
Shlomi Fish        [email-masked] 
Home Page:         http://t2.technion.ac.il/~shlomif/
Home E-mail:       [email-masked]

The prefix "God Said" has the extraordinary logical property of 
converting any statement that follows it into a true one.