我已经在OSX上启动了一个Eclipse RCP项目并且希望继续使用Windows 10进行开发,但是当我将项目导入windows时,代码中的所有SWT导入都显示错误,我试图下载org.eclipse .swt作为一个进入eclipse的项目并将其导入到所有其他项目中,但是当我尝试运行该应用程序时,我得到以下异常:
java.lang.NoClassDefFoundError:org / eclipse / swt / widgets / Display 在org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:144) 在org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
我还注意到,当我尝试运行项目时,它为osx定义了bootloader,而不是windows,如下所示:
BootLoader常量:OS = macosx,ARCH = x86_64,WS = cocoa,NL = en_IE
我想知道是否有人会就如何在Eclipse RCP中进行跨平台开发提出任何建议?
答案 0 :(得分:0)
最好的方法是使用Maven,为每个平台定义特定的配置文件。 您可以尝试以下pom定义(这仅适用于SWT),使其适应您的应用程序(更改内容并添加依赖项):
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>yourGroupId</groupId>
<artifactId>YourArtifactId</artifactId>
<version>1.0.0-SNAPSHOT</version>
<properties>
<swt.version>SWT_Version</swt.version>
</properties>
<repositories>
<repository>
<id>maven-eclipse-repo</id>
<url>http://maven-eclipse.github.io/maven</url>
</repository>
</repositories>
<dependencies>
<dependency>
....//your dependencies
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.3</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>win32-x86</id>
<dependencies>
<dependency>
<groupId>org.eclipse.swt</groupId>
<artifactId>org.eclipse.swt.win32.win32.x86</artifactId>
<version>${swt.version}</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>win32-x86-64</id>
<dependencies>
<dependency>
<groupId>org.eclipse.swt</groupId>
<artifactId>org.eclipse.swt.win32.win32.x86_64</artifactId>
<version>${swt.version}</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>linux-x86</id>
<dependencies>
<dependency>
<groupId>org.eclipse.swt</groupId>
<artifactId>org.eclipse.swt.gtk.linux.x86</artifactId>
<version>${swt.version}</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>linux-x86-64</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>org.eclipse.swt</groupId>
<artifactId>org.eclipse.swt.gtk.linux.x86_64</artifactId>
<version>${swt.version}</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>macosx-x86-64</id>
<dependencies>
<dependency>
<groupId>org.eclipse.swt</groupId>
<artifactId>org.eclipse.swt.cocoa.macosx.x86_64</artifactId>
<version>${swt.version}</version>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
我希望这有帮助! ;)