在这里我得到空指针异常: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) cm.lookup("recognizer"); 处找不到另一个类异常;请告诉我如何解决它。?