Вопрос

I'm developing a cross-platform RCP application in Win 7 (64bit), Indigo/Java 1.6, building the product with Tycho.

While the application runs fine from the Run Configuration within eclipse, and the Win x_86_64 build runs fine as well, I get the following errors on both xubuntu (with OpenJDK Java 6 Runtime (1.6.0_24) and Mac OS X (1.6.0_35).

The error (on Linux) looks like this (running 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.

I'm sure I've come across this before, and I think it was something stupid (this has happened on Windows before AFAIK, and re-installing Java fixed it for some reason). In this case, however, I think it must be to do with the build/target platform/Tycho setup.

The part of my parent POM responsible for the cross-platform build looks unsuspicious enough:

    <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>

Does anybody have any ideas why this might not work? Many thanks!

Это было полезно?

Решение

This is not how you run an Eclipse RCP application.

You either need to launch it with the appropriate native launcher, or with a java -jar plugins/org.eclipse.equinox.launcher_(yourVersion).jar (see this documentation) and probably further arguments to select your application.

Also, you need to make sure that you have the bundles in your application that Equinox needs to start up. You can do this by including the feature org.eclipse.rcp in you product.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top