HelloWorldSWT tutorial program does not compile [message #1830863] |
Wed, 05 August 2020 07:58  |
Eclipse User |
|
|
|
Dear forum members,
I have just installed Eclipse again and tried to follow the HelloWorld tutorial. It worked and I think it also did last time.
Then on to the HelloWorldSWT tutorial, which didn't work last time.
I managed I think to import what the tutorial refers to as the 'SWT project' : On the left of the Eclipse window there is now something called 'org.eclipse.swt'.
I was able to follow the remainder of the tutorial without problem and as the tutorial admits, doing so results in several compilation errors. As a consequence, the program can't run.
The program is as follows :
import jdk.nashorn.tools.Shell;
public class HelloWorldSwT {
public static void main(String[] args) {
Display display = new Display() ;
Shell shell = new Shell(display) ;
Shell.setText("Hello World !") ;
shell.open() :
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep() ;
}
display.dispose() ;
}
}
Here are the compiler complaints :
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Display cannot be resolved to a type
Display cannot be resolved to a type
The method setText(String) is undefined for the type Shell
The method open() is undefined for the type Shell
Syntax error on token ":", ; expected
The method isDisposed() is undefined for the type Shell
at HelloWorldSwT.main(HelloWorldSwT.java:6)
I suspect that if I continue using Eclipse, I will encounter that type of problem again. Is there somewhere a good guide explaining how to make Eclipse find stuff ?
|
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.12393 seconds