私はEclipse IDEを使って簡単なプログラムを書いています
コードは次のとおりです
package java_pr;
import java.io.Console;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RegexTestHarness {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Console console = System.console();
if (console == null) {
System.err.println("No Console !!");
System.exit(1);
}
while (true) {
Pattern pattern = Pattern.compile(console.readLine("%nEnter your regex: "));
Matcher matcher = pattern.matcher("Enter input string to search: ");
boolean found = false;
while (matcher.find()) {
console.format("I found the text" +
"\"%s\" starting at " +
"index %d and ending at index %d.%n",
matcher.group(),
matcher.start(),
matcher.end());
found = true;
}
if (!found) {
console.format("No match found.%n");
}
}
}
}
コマンドプロンプトからこのプログラムを実行しようとすると、次のエラーが発生しました
java.lang.ClassLoader.loadClass(不明なソース) の loadClass(不明なソース) メイン クラスが見つかりませんでした: RegexTestHarness。プログラムは終了します。
日食で正常に動作している間