Java Gate嵌入式

时间:2017-01-07 15:39:51

标签: java gate

我正在尝试使用Gate embedded来提取一些实体。 我从中包含了jar文件 bin和lib文件夹 这是代码:

    Out.prln("Initialising GATE...");
    Properties props = System.getProperties();
    props.setProperty("gate.home", "/Applications/GATE_Developer_8.2");
    SwingUtilities.invokeAndWait(new Runnable() { 
        public void run() {
            MainFrame.getInstance().setVisible(true);
            try {
                Factory.newDocument("This is a document");
            } catch (ResourceInstantiationException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();

但我总是得到以下异常。有谁知道我做错了什么?感谢

Exception in thread "main" java.lang.reflect.InvocationTargetException
    at java.awt.EventQueue.invokeAndWait(EventQueue.java:1312)
    at java.awt.EventQueue.invokeAndWait(EventQueue.java:1287)
    at javax.swing.SwingUtilities.invokeAndWait(SwingUtilities.java:1348)
    at gate.Gate.main(Gate.java:25)
Caused by: java.lang.NoSuchMethodError: gate.Gate.getUserConfig()Lgate/util/OptionsMap;
    at gate.swing.XJFileChooser.getLocations(XJFileChooser.java:140)
    at gate.swing.XJFileChooser.<init>(XJFileChooser.java:70)
    at gate.gui.MainFrame.<init>(MainFrame.java:493)
    at gate.gui.MainFrame.getInstance(MainFrame.java:352)
    at gate.gui.MainFrame.getInstance(MainFrame.java:348)
    at gate.Gate$1.run(Gate.java:27)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:301)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:749)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:702)
    at java.awt.EventQueue$3.run(EventQueue.java:696)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:719)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

2 个答案:

答案 0 :(得分:0)

您遇到此错误,因为该类位于类路径中,但其版本与您的需求不匹配。找到该类但您调用的方法在该类的版本中不存在。

我认为您应该使用更新版本的GATE库。

例如,此版本https://gate.ac.uk/releases/gate-3.1-build2270-ALL/doc/javadoc/包含提供公共方法OptionsMap getUserConfig()的{​​{3}}类。

答案 1 :(得分:0)

查看堆栈跟踪时,我认为您的主类名为gate.Gate - 与GATE库的中心类名称相同。而这种名称冲突导致了这个问题。

只需重命名您的类或更改其包,错误就应该消失。