ich habe hier den gcj, gij und eclipse-sdk installiert. Da müsste doch alles dabei sein um swt Programme auszuführen?
Wenn ich aber ein einfaches Hello-World Programm kompilieren will:
Code: Alles auswählen
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Label;
public class SWTHello {
public static void main (String [] args) {
Display display = new Display ();
final Shell shell = new Shell(display);
RowLayout layout = new RowLayout();
layout.justify = true;
layout.pack = true;
shell.setLayout(layout);
shell.setText("Hello, World!");
Label label = new Label(shell, SWT.CENTER);
label.setText("Hello, World!");
shell.pack();
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
}
Code: Alles auswählen
javac SWTHello.java
SWTHello.java:5: error: Class or interface 'org.eclipse.swt.widgets.Label' not found in import.
import org.eclipse.swt.widgets.Label;
^
SWTHello.java:9: error: Type 'Display' not found in the declaration of the local variable 'display'.
Display display = new Display ();
^
SWTHello.java:10: error: Type 'Shell' not found in the declaration of the local variable 'shell'.
final Shell shell = new Shell(display);
^
SWTHello.java:11: error: Type 'RowLayout' not found in the declaration of the local variable 'layout'.
RowLayout layout = new RowLayout();
^
SWTHello.java:16: error: Type 'Label' not found in the declaration of the local variable 'label'.
Label label = new Label(shell, SWT.CENTER);
^
5 errors
Danke!
EDIT: Hat sich erledigt, ich habe vergessen CLASSPATH auf /usr/share/java/swt-gtk.jar zu setzen