无法在Eclipse中将库添加到xtext Project(返回错误) [英] Cannot add libraries to xtext Project in Eclipse (returns error)

查看:308
本文介绍了无法在Eclipse中将库添加到xtext Project(返回错误)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我使用默认值(以简单的Greetings语法为例)创建了一个xtext项目。

Firstly, I created an xtext project using default values (with the simple Greetings grammar which comes as an example).

我创建了一个.java文件,其中包含一些代码(可以在下面看到)并将其添加到验证文件夹。

I created then a .java file with some code (that can be seen below) and added it to the validation folder.

我已经像在普通Java项目中一样将一些jar加载到了构建路径。如果我将特定的Java文件作为独立文件运行,它将加载库并运行代码。 Java文件非常简单:

I have loaded some jars to the build path as I would do in a normal Java Project. If I run my specific java file as a standalone it will load the libraries and run the code. The java file is quite simple:

import org.semanticweb.owlapi.apibinding.OWLManager;
import org.semanticweb.owlapi.model.OWLOntologyCreationException;
import org.semanticweb.owlapi.model.OWLOntologyManager;
import org.xtext.example.mydsl.myDsl.Greeting;

public static void main(String[] args){
    Greeting hey = null;
    try {
        test(hey);
    } catch (OWLOntologyCreationException e) {
        e.printStackTrace();
    }
}

public static void test(Greeting imp) throws OWLOntologyCreationException {
    OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
    System.out.println("success!");     
}

但是,如果从.xtend验证程序文件中调用测试功能,则会产生此错误:

However, if a call the "test" function from the .xtend validator file, it will generate this error:

java.lang.NoClassDefFoundError: org/semanticweb/owlapi/model/OWLOntologyCreationException
at org.xtext.example.mydsl.validation.MyDslValidator.checkGreetingStartsWithCapital(MyDslValidator.java:24)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
/* (has some more "at" in the middle) */
Caused by: java.lang.ClassNotFoundException: org.semanticweb.owlapi.model.OWLOntologyCreationException cannot be found by org.xtext.example.mydsl_1.0.0.qualifier
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:461)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:372)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:364)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:161)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 32 more

当它提到无法通过org.xtext.example找到。 mydsl_1.0.0.qualifier,我认为问题出在清单中,但我尝试了各种可能的方式将库添加到清单中,但无济于事。

When it mentioned "cannot be found by org.xtext.example.mydsl_1.0.0.qualifier" I assumed the problem was in the manifest, but I've tried adding the libraries to the manifest in every way possible but to no avail.

推荐答案

如果将库添加到构建路径

if you add libs to the buildpath


  1. 将其复制到插件中的新lib文件夹中

  2. 调整清单并将其添加为条目(运行时选项卡,类路径部分)

  3. 添加要包含在build.properties中的罐子(应该有警告和快速修复)

这篇关于无法在Eclipse中将库添加到xtext Project(返回错误)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆