我正在學習perl語言。 我做了一個簡單的perl腳本(如下圖所示)。使用Java語言在NetBean中以簡單的perl腳本運行
#!/usr/bin/perl
use strict;
use warnings;
print "hi Lala\n";
我想在NetBean中使用java語言運行此腳本。 我的代碼如下:
public class javaProgram {
public static void main(String[] args) {
Process process;
try
{
String testFile = "perl C:\\Strawberry\\perl_tests\\hello_world.pl";
process = Runtime.getRuntime().exec(testFile);
process.getOutputStream();
process.waitFor();
if(process.exitValue() == 0)
{
System.out.println("Command Successful");
}
else
{
System.out.println("Command Failure");
}
}
catch(Exception e)
{
System.out.println("Exception: "+ e.toString());
}
}
}
但我得到這個錯誤
異常:java.io.IOException異常:不能運行程序 「perl的C:\草莓\ perl_tests \ hello_world.pl」: CreateProcess錯誤= 2,系統找不到指定的文件
我已將腳本保存爲hello_world.pl,如上所示。所以,我不確定我做錯了什麼。 它是NetBean問題嗎?腳本問題?但是當我使用Strawberry IDE運行腳本時,沒有任何問題或錯誤。
的perl沒有找到!添加完整路徑 – Jens