This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have David & Dawn Griffiths on-line!
See this thread for details.
Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Running SWT Applications Outside of Eclipse

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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() {
super();
}

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() ;
thisClass.sShell.open();

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

private void createSShell() {
sShell = new org.eclipse.swt.widgets.Shell();
sShell.setSize(new org.eclipse.swt.graphics.Point(300,200));
sShell.setText("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(y.java:34)

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?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic