Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » HelloWorldSWT tutorial
HelloWorldSWT tutorial [message #906941] Sun, 02 September 2012 21:31 Go to next message
Jason Clark is currently offline Jason Clark
Messages: 3
Registered: August 2012
Junior Member
Yes, I'm new to Java and Eclipse (an incredible tool!).

I walked through the tutorial to build HelloWorld! and it worked. Then I tried walking through the tutorial for HelloWorldSWT. When I had problems, I deleted the HelloWorldSWT project and started over, I let the tutorial "do it for me" as much as possible.

But it still doesn't work.

I've tried the Organize Imports and can see no change. Where would I look to see the changes from this command?

Here's the code for the HelloWorldSWT.java:

public class HelloWorldSWT {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub

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's the errors after I compile:

Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Display cannot be resolved to a type
Display cannot be resolved to a type
Shell cannot be resolved to a type
Shell cannot be resolved to a type

at HelloWorldSWT.main(HelloWorldSWT.java:9)

The tutorial says:
You will get compile errors. Right click in the Java editor and select Source > Organize Imports, then save your changes.

I've done this. Many times. I've tried the ctrl+shift+o and I still get the compile errors.

Why does this not work?

I really appreciate any help you can give me. Thank you!

Re: HelloWorldSWT tutorial [message #908566 is a reply to message #906941] Wed, 05 September 2012 11:16 Go to previous messageGo to next message
Glen Zanabe is currently offline Glen Zanabe
Messages: 1
Registered: September 2012
Junior Member
the same thing happened to me this is how I fixed it. go back to the import SWT part of the tutorial and make sure you import org.eclipse.swt.{platform}.{os}.{arch} and not the org.eclipse.swt.like mine would be
org.eclipse.swt.win32.win32.x86 then continue on with the rest of the tutorial. when you click Source > Organize Imports in the java editor these two lines of code should appear

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

at the top automatically and the compile errors should be resolved.From there just run your application.

Hope this helps !!!! Rolling Eyes Rolling Eyes
Re: HelloWorldSWT tutorial [message #990932 is a reply to message #908566] Fri, 14 December 2012 20:53 Go to previous messageGo to next message
luis villegas is currently offline luis villegas
Messages: 1
Registered: December 2012
Junior Member
I am running 64 bit operating system windows 7 but I had to add org.eclipse.swt.win32.32x86 to make my swt application work. If I had not then the 2 import lines at the top of my project would not display when organizing imports. Do you have an idea of why that is?
Re: HelloWorldSWT tutorial [message #1012203 is a reply to message #990932] Wed, 20 February 2013 23:39 Go to previous messageGo to next message
Andrew Geriane is currently offline Andrew Geriane
Messages: 1
Registered: February 2013
Junior Member
Glen just find a 32 bit version of eclipse. Doesn't matter if it is indigo or MAC version if you are using MAC.

This is what I have also. The only missing code is

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

THe is the reason we are getting the error:

instances of this class is responsible for managing the connection between SWT.



Re: HelloWorldSWT tutorial [message #1047614 is a reply to message #908566] Tue, 23 April 2013 08:50 Go to previous messageGo to next message
Aditya Iyer is currently offline Aditya Iyer
Messages: 3
Registered: April 2013
Junior Member
hi i cant seem to find org.eclipse.swt.{platform}.{os}.{arch}
i can only find this org.eclipse.swt 3.0.8.
pls help Confused
Re: HelloWorldSWT tutorial [message #1047840 is a reply to message #1047614] Tue, 23 April 2013 14:23 Go to previous message
Baruch Youssin is currently offline Baruch Youssin
Messages: 25
Registered: April 2013
Junior Member
I think I have been through this.
Have a look:
http://www.eclipse.org/forums/index.php/t/477829/
Good luck!
Rolling Eyes
Previous Topic:Need help with a project
Next Topic:I'm New here
Goto Forum:
  


Current Time: Mon Apr 21 00:40:44 EDT 2014

Powered by FUDForum. Page generated in 0.08157 seconds