私はperl言語の学習を進めています。 私は単純なperlスクリプトを作成しました(以下に示すように)。Java言語を使用してNetBeansで単純なperlスクリプトとして実行
#!/usr/bin/perl
use strict;
use warnings;
print "hi Lala\n";
このスクリプトは、Java言語を使用してNetBeansで実行しようとしています。
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 error = 2、指定されたファイルが見つかりません
上記のようにディレクトリにhello_world.plというスクリプトを保存しました。だから、私は何が間違っているのか分かりません。 NetBeanに問題がありますか?スクリプトの問題?しかし、Strawberry IDEを使用してスクリプトを実行すると、問題やエラーは発生しません。
のperlが見つかりません!完全なパスを追加する – Jens