我试图运行代码使用protege-owl。因此,我将protege.jarprotege-owl.jar添加到库中以导入edu.stanford.smi.protegex.owl.*edu.stanford.smi.protege.*

我还添加了耶拿jar文件,以用于下一步。

首先,我编写了简单的代码以查看其工作原理:

 import java.lang.Object;
 import edu.stanford.smi.protege.*;
 import edu.stanford.smi.protegex.owl.*;
 import edu.stanford.smi.protegex.owl.jena.JenaOWLModel;
 import edu.stanford.smi.protegex.owl.model.OWLNamedClass;
public class Main {
    public static void main(String[] args) {
           // TODO code application logic here
          JenaOWLModel model=ProtegeOWL.createJenaOWLModel();
          OWLNamedClass c= model.createOWLNamedClass("A");
          System.out.print(c.getName());
       }
}


但这给了我这个错误:

CONFIG: Protege 3.0 Build 141, JVM 1.6.0_20-b02, memory=259M, Windows 7, encoding=UTF-8, language=fa, country=IR
WARNING: Look and feel not found: com.jgoodies.plaf.plastic.PlasticLookAndFeel -- SystemUtilities.loadLookAndFeel()
WARNING: Plugins directory not found: C:\Users\mona\Documents\NetBeansProjects\JavaApplication3\plugins -- PluginUtilities.getPluginsDir()
WARNING: Exception Caught -- java.lang.NoClassDefFoundError: com/toedter/calendar/JDateChooser
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:247)
        at edu.stanford.smi.protege.plugin.PluginUtilities.isLoadableClass(Unknown Source)
        at edu.stanford.smi.protege.plugin.PluginUtilities.checkPlugin(Unknown Source)
        at edu.stanford.smi.protege.plugin.PluginUtilities.checkPlugins(Unknown Source)
        at edu.stanford.smi.protege.plugin.PluginUtilities.processManifest(Unknown Source)
        at edu.stanford.smi.protege.plugin.PluginUtilities.loadPluginsWithClassLoader(Unknown Source)
        at edu.stanford.smi.protege.plugin.PluginUtilities.createClassLoaderAndLoadPlugins(Unknown Source)
        at edu.stanford.smi.protege.plugin.PluginUtilities.loadPlugins(Unknown Source)
        at edu.stanford.smi.protege.plugin.PluginUtilities.loadSystemPlugins(Unknown Source)
        at edu.stanford.smi.protege.plugin.PluginUtilities.loadPlugins(Unknown Source)
        at edu.stanford.smi.protege.plugin.PluginUtilities.init(Unknown Source)
        at edu.stanford.smi.protege.plugin.PluginUtilities.<clinit>(Unknown Source)
        at edu.stanford.smi.protege.util.SystemUtilities.init(Unknown Source)
        at edu.stanford.smi.protege.util.SystemUtilities.<clinit>(Unknown Source)
        at edu.stanford.smi.protege.model.Project.<clinit>(Unknown Source)
        at edu.stanford.smi.protegex.owl.ProtegeOWL.createJenaOWLModel(ProtegeOWL.java:32)
        at javaapplication3.Main.main(Main.java:25)
Caused by: java.lang.ClassNotFoundException: com.toedter.calendar.JDateChooser
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method) . . . .


我能做什么 ?



更新:
我将protege.jar替换为protege-3.5.jar,现在它给出了:

Exception in thread "main" java.lang.NoSuchMethodError: edu.stanford.smi.protege.model.SystemFrames.replaceFrame(Ledu/stanford/smi/protege/model/Frame;)V
        at edu.stanford.smi.protegex.owl.model.impl.AbstractOWLModel.createSystemFrames(AbstractOWLModel.java:544)
        at edu.stanford.smi.protege.model.DefaultKnowledgeBase.<init>(DefaultKnowledgeBase.java:79)
        at edu.stanford.smi.protegex.owl.model.impl.AbstractOWLModel.<init>(AbstractOWLModel.java:318)
        at edu.stanford.smi.protegex.owl.jena.JenaOWLModel.<init>(JenaOWLModel.java:62)
        at edu.stanford.smi.protegex.owl.jena.JenaKnowledgeBaseFactory.createKnowledgeBase(JenaKnowledgeBaseFactory.java:55)
        at edu.stanford.smi.protege.model.Project.createDomainKB(Project.java:429)
        at edu.stanford.smi.protege.model.Project.createDomainKnowledgeBase(Project.java:447)
        at edu.stanford.smi.protege.model.Project.<init>(Project.java:359)
        at edu.stanford.smi.protege.model.Project.<init>(Project.java:341)
        at edu.stanford.smi.protege.model.Project.createNewProject(Project.java:545)
        at edu.stanford.smi.protegex.owl.ProtegeOWL.createJenaOWLModel(ProtegeOWL.java:32)
        at javaapplication3.Main.main(Main.java:24)
Java Result: 1


问题出在哪里?

最佳答案

我从其他链接下载了3.24MB的protege-owl.jar,现在可以使用了。

08-25 14:16