Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » HelloWorldSWT tutorial
HelloWorldSWT tutorial [message #906941] Mon, 03 September 2012 01:31 Go to next message
Jason Clark is currently offline Jason ClarkFriend
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 15:16 Go to previous messageGo to next message
Glen Zanabe is currently offline Glen ZanabeFriend
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] Sat, 15 December 2012 01:53 Go to previous messageGo to next message
luis villegas is currently offline luis villegasFriend
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] Thu, 21 February 2013 04:39 Go to previous messageGo to next message
Andrew Geriane is currently offline Andrew GerianeFriend
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 12:50 Go to previous messageGo to next message
Aditya Iyer is currently offline Aditya IyerFriend
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 18:23 Go to previous messageGo to next message
Baruch Youssin is currently offline Baruch YoussinFriend
Messages: 29
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
icon14.gif  Re: HelloWorldSWT tutorial [message #1635564 is a reply to message #906941] Wed, 25 February 2015 21:28 Go to previous messageGo to next message
Mario Ramirez Velasquez is currently offline Mario Ramirez VelasquezFriend
Messages: 2
Registered: February 2015
Junior Member
Thanks, works for me.
icon14.gif  Re: HelloWorldSWT tutorial [message #1651919 is a reply to message #906941] Thu, 05 March 2015 15:40 Go to previous message
Mario Ramirez Velasquez is currently offline Mario Ramirez VelasquezFriend
Messages: 2
Registered: February 2015
Junior Member
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 Apr 19 07:16:39 GMT 2024

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

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

Back to the top