Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Running SWT Applications Outside of Eclipse  RSS feed

Peter Sapl
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I created a very, very simple SWT project in Eclipse.

public class y {
private org.eclipse.swt.widgets.Shell sShell = null;
public y() {

public static void main(String[] args) {
System.setProperty("java.library.path", "C:\\programme\\java\\eclipse\\plugins\\org.eclipse.swt.win32_3.0.1\\os\\win32\\x86");
org.eclipse.swt.widgets.Display display = org.eclipse.swt.widgets.Display.getDefault();
y thisClass = new y();
thisClass.createSShell() ;;

while (!thisClass.sShell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep ();

private void createSShell() {
sShell = new org.eclipse.swt.widgets.Shell();

This project only shows an empty window. Without setting (Arguments->VM Arguments) for the correct SWT library path in the configuration section of Eclipse (Djava.library.path="C:\programme\java\eclipse\plugins\org.eclipse.swt.win32_3.0.1\os\win32\x86") the project works because of setting this in the first line of the main method.

Afterwards I created a Jar-File which includes the above mentioned class and a manifest-file containing the following:

Manifest-Version: 1.0
Main-Class: y

java -classpath .;%classpath%;C:\java\x\test1.jar -Djava.library.path="C:\Programme\Java\eclipse\plugins\org.eclipse.swt.win32_3.0.1\os\win32\x86" -jar test1.jar -> Error: Exception in thread �main� java.lang.NoClassDefFoundError: org/eclipse/swt/widgets/Display at y.main(

java -classpath .;%classpath%;C:\java\x\test1.jar -Djava.library.path="C:\Programme\Java\eclipse\plugins\org.eclipse.swt.win32_3.0.1\os\win32\x86" y -> that�s ok

Why does �java� not find the �org/eclipse/swt/widgets/Display�-class although in the classpath the right path to �swt.jar� is set, when I use a jar-file?
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!