ここでは、次の場所でnullポインタ例外が発生しています:ConfigurationManager cm = new ConfigurationManager(url);
public static void main(String[] args) throws IOException,
InstantiationException, ClassNotFoundException, SQLException {
HelloWorld h = new HelloWorld();
h.setVisible(true);
try {
URL url;
if (args.length > 0)
url = new File(args[0]).toURI().toURL();
else {
url = HelloWorld.class.getResource("helloworld.config.xml");
}
System.out.println("Loading...");
ConfigurationManager cm = new ConfigurationManager(url);
Recognizer recognizer = (Recognizer) cm.lookup("recognizer");
Microphone microphone = (Microphone) cm.lookup("microphone");
recognizer.allocate();
if (microphone.startRecording()) {
System.out.println("Say: Something");
while (true) {
String printOnTextArea = null;
System.out
.println("Start speaking. Press Ctrl-C to quit.\n");
Result result = recognizer.recognize();
if (result != null) {
String resultText = result.getBestFinalResultNoFiller();
これを解決する方法を教えてください。
構成ファイルをHelloWorld.javaの同じパッケージに入れましたが、Recognizer Recognitionr =(Recognizer)cm.lookup( "recognizer");でクラスが見つからないという別の例外が発生したため、問題は解決しました。解決方法を教えてください。