简体   繁体   English

使用maven-dependency-plugin运行带有eclipse swt依赖关系的Java jar

[英]Running a java jar with eclipse swt dependencies with maven-dependency-plugin

I'm making an eclipse plugin that I also want to make it work command line. 我正在制作一个eclipse插件,我也想使其在命令行下工作。 As normal the usual problem is encountering the eclipse dependencies in command-line: 通常,通常的问题是在命令行中遇到Eclipse依赖项:

Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/swt/widgets/Layout
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:56)
Caused by: java.lang.ClassNotFoundException: org.eclipse.swt.widgets.Layout
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 3 more

Now I know there is an eclipse FAQ for this problem however here is a bit different. 现在,我知道有一个关于这个问题的日食常见问题解答,但是这里有点不同。 I'm using Maven for build with the maven-dependency-plugin to add jars I need from other project to this jar as dependencies: 我正在使用Maven与maven-dependency-plugin进行构建,以将其他项目所需的jar添加到此jar作为依赖项:

<build>
    <plugins>
        <plugin>
            <!-- Copy non-Eclipse plugins to target/dependency so that may be referenced 
                for runtime use. -->
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.8</version>
            <executions>
                <execution>
                    <id>copy-dependencies</id>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
                        <!-- seems the line below is needed otherwise every second run the 
                            copy-dependencies fails , link to bug : https://bugs.eclipse.org/bugs/show_bug.cgi?id=393978 -->
                        <includeScope>runtime</includeScope>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

The dependencies in my Manifest file looks like this: 我的清单文件中的依赖项如下所示:

Rsrc-Class-Path: ./ 
 lib/jcommon-1.0.23.jar
 lib/jfreechart-1.0.19.jar
 lib/jfreechart-1.0.19-swt.jar
 lib/jfreechart-1.0.19-experimental.jar
 lib/swt.jar
 target/dependency/my.first.package.jar
 target/dependency/my.second.package.jar
Class-Path: .
Rsrc-Main-Class: my.package.Main
Main-Class: org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader

Bundle-ClassPath: .,
 lib/jcommon-1.0.23.jar,
 lib/jfreechart-1.0.19-experimental.jar,
 lib/jfreechart-1.0.19-swt.jar,
 lib/jfreechart-1.0.19.jar,
 lib/swt.jar

Require-Bundle: org.eclipse.core.runtime,
 org.eclipse.ui,
 my.first.package;visibility:=reexport,
 my.second.package;visibility:=reexport,
 ca.odell.glazedlists,
 org.eclipse.nebula.widgets.nattable.core,
 org.eclipse.core.resources,
 org.eclipse.swt

As you can see I added an swt.jar to a lib inside my project and am referencing it there as to have all my dependencies inside my jar. 如您所见,我在项目内的lib中添加了一个swt.jar,并在那里引用它,以使我的所有依赖项都在jar中。

Still I get the above error when I try to run it command line as if the swt.jar isn't there. 当我尝试在命令行中运行swt.jar时,仍然出现上述错误。

What am I missing? 我想念什么?

如果要使Eclipse插件命令行友好,最好的办法是让该插件还定义一个Eclipse应用程序,然后可以从命令行调用它: https : //wiki.eclipse.org/FAQ_How_do_I_create_an_application%3F

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法在 org.apache.maven.plugins:maven-dependency-plugin:jar:2.10 收集依赖项 - Failed to collect dependencies at org.apache.maven.plugins:maven-dependency-plugin:jar:2.10 Java Maven依赖插件ClassNotFoundException在运行时 - Java maven-dependency-plugin ClassNotFoundException at runtime maven-dependency-plugin 未显示测试范围的依赖项 - maven-dependency-plugin not showing test-scoped dependencies Spring 引导核心依赖项被 maven-dependency-plugin 视为未使用 - Spring boot core dependencies seen as unused by maven-dependency-plugin 使用maven-dependency-plugin使用maven 3.1创建可运行的jar不会创建可运行的jar - Create runnable jar with maven 3.1 using maven-dependency-plugin doesn't create runnable jar maven-jar-plugin存储库布局与maven-dependency-plugin组合 - maven-jar-plugin repository layout combined with maven-dependency-plugin maven-dependency-plugin忽略outputDirectory配置 - maven-dependency-plugin ignores outputDirectory configuration Maven的依赖插件不排除匹配的文件 - maven-dependency-plugin not excluding matching files maven-dependency-plugin没有使用destFileName? - destFileName not used by maven-dependency-plugin? Maven依赖插件和带有SOURCE RetentionPolicy的注释 - Maven-dependency-plugin and annotations with SOURCE RetentionPolicy
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM