0

我有一堂课如下:

public class JSemcorProcessor {

IConcordanceSet semcor;
String[] directories = { "brown1", "brown2", "brownv" };

public JSemcorProcessor() throws MalformedURLException {
    // construct the URL to the Semcor directory
    String path = "./files/semcor3.0/";
    URL url = new URL("file", null, path);

    // construct the semcor object and open it
    semcor = new Semcor(url);
    semcor.open();
}

public static void main(String[] args) throws IOException, ParseException {

    JSemcorProcessor jsp = new JSemcorProcessor();
    SynsetGraph graph = jsp.startOne("br-a06");

}
.......
}

当我调用 main() 时它运行良好。但现在我想在 Applet 中使用这个类:

public void init() {

    JSemcorProcessor jsp = null;
    SynsetGraph graph = null;
    try {
        jsp = new JSemcorProcessor();
        graph = jsp.startOne("br-a06");
    } catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } 
........
}

出现这样的异常:

java.lang.IllegalArgumentException
    at edu.mit.jsemcor.main.Semcor.<init>(Semcor.java:105)
    at edu.mit.jsemcor.main.Semcor.<init>(Semcor.java:90)
    at edu.mit.jsemcor.main.Semcor.<init>(Semcor.java:77)
    // semcor = new Semcor(url);
    at edu.njit.tagging.JSemcorProcessor.<init>(JSemcorProcessor.java:40)
    // jsp = new JSemcorProcessor();
    at org.jgrapht.demo.JGraphAdapterDemo.init(JGraphAdapterDemo.java:157)
    at sun.applet.AppletPanel.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

为什么在 main() 中工作的相同代码在 Applet 中不起作用?似乎 URL 对象在 Semcor 中调用了这个问题。

谢谢。

4

0 回答 0