Skip to main content



      Home
Home » Newcomers » Newcomers » HelloWorldSWT tutorial
HelloWorldSWT tutorial [message #906941] Sun, 02 September 2012 21:31 Go to next message
Eclipse UserFriend
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
Eclipse UserFriend
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
Eclipse UserFriend
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
Eclipse UserFriend
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
Eclipse UserFriend
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 messageGo to next message
Eclipse UserFriend
I think I have been through this.
Have a look:
http://www.eclipse.org/forums/index.php/t/477829/
Good luck!
Rolling Eyes
icon14.gif  Re: HelloWorldSWT tutorial [message #1635564 is a reply to message #906941] Wed, 25 February 2015 16:28 Go to previous messageGo to next message
Eclipse UserFriend
Thanks, works for me.
icon14.gif  Re: HelloWorldSWT tutorial [message #1651919 is a reply to message #906941] Thu, 05 March 2015 10:40 Go to previous message
Eclipse UserFriend
Thanks, works for me.
Previous Topic:Unable to Install New Software in China
Next Topic:Project files and folders sorting by capital letter first?!
Goto Forum:
  


Current Time: Fri Jul 25 20:15:49 EDT 2025

Powered by FUDForum. Page generated in 0.09092 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top