In my project i have imported perl scripts . so my project now contains:
- A class file consisting of java code to execute a task and
- A perl script , which need to be called in the above (1.) class.
The main operation i need to achieve is : i want to call the perl script present in the same project to execute in the mid of the java code.
something like this:
public class Demo_Java{
// ...
System.out.println("entered 1st###############");
Process p = Runtime.getRuntime().exec("perl /javaProject/perlScript.pl");
p.waitFor();
}
But this is not working , i simply mentioned it for illustrating the requirement..
Is there any way i can call the perl script into the java file ?
EDIT: I tried running the following code :
process = Runtime.getRuntime().exec("perl C:/javaProject/perlScript.pl ");
process.waitFor();
if(process.exitValue() == 0)
{
System.out.println("Command execution passed");
}
else
{
System.out.println("Command execution Failed");
}
and am getting error as -> command execution failed
.. may be this is due to syntax error on Runtime.getRuntime().exec("perl C:/javaProject/perlScript.pl ");
, is this correct format to write exec ?