我正在用Win7(64位),Indigo/Java1.6开发一个跨平台的RCP应用程序,用Tycho构建产品。
虽然应用程序在eclipse中的运行配置下运行良好,Win x_86_64构建也运行得很好,但我在xubuntu (使用OpenJDK Java6Runtime (1.6.0_24)和Mac (1.6.0_35) )上都得到了以下错误。
错误(在Linux上)如下所示(运行java myprogram):
Exception in thread "main" java.lang.NoClassDefFoundError: myprogram
Caused by: java.lang.ClassNotFoundException: myprogram
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: myprogram. Program will exit.我确信我以前遇到过这种情况,我认为这是很愚蠢的事情(这在AFAIK之前就在Windows上发生过,由于某种原因,重新安装Java修复了它)。然而,在这种情况下,我认为这一定与构建/目标平台/Tycho设置有关。
我的父级POM中负责跨平台构建的部分看起来并不可疑:
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
<resolver>p2</resolver>
<pomDependencies>consider</pomDependencies>
<!-- configure the p2 target environments for multi-platform build -->
<environments>
<environment>
<os>linux</os>
<ws>gtk</ws>
<arch>x86</arch>
</environment>
<environment>
<os>linux</os>
<ws>gtk</ws>
<arch>x86_64</arch>
</environment>
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86</arch>
</environment>
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86_64</arch>
</environment>
<environment>
<os>macosx</os>
<ws>cocoa</ws>
<arch>x86_64</arch>
</environment>
</environments>
</configuration>
</plugin>有没有人知道为什么这可能不起作用?非常感谢!
发布于 2012-10-15 21:31:16
这不是运行Eclipse RCP应用程序的方式。
您需要使用适当的本机启动器启动它,或者使用java -jar plugins/org.eclipse.equinox.launcher_(yourVersion).jar (请参阅this documentation)以及可能需要更多参数来选择您的application。
此外,您还需要确保您的应用程序中有Equinox需要启动的包。您可以通过在您的产品中包含功能org.eclipse.rcp来完成此操作。
https://stackoverflow.com/questions/12893506
复制相似问题