Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 311633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:56:34+00:00 2026-05-12T07:56:34+00:00

I’m an Eclipse newbie and I’m trying to build a mixed AWT/SWT application. Here’s

  • 0

I’m an Eclipse newbie and I’m trying to build a mixed AWT/SWT application. Here’s my code:

public class HelloWorldSWT {

    public static void main(String[] args) {
        Frame frame = new Frame("My AWT Frame"); // java.awt.Frame
        frame.setLayout( new BorderLayout() );
        Canvas canvas = new Canvas(); // java.awt.Canvas
        frame.add(canvas, BorderLayout.CENTER);
        frame.setVisible(true);

        Display display = new Display(); // display object to manage SWT lifecycle.
        Shell swtShell = SWT_AWT.new_Shell(display, canvas);
        Button m_button = new Button(swtShell, SWT.PUSH);
        m_button.setText( "button" );

        // invoke the AWT frame rendering by making the frame visible
        // This starts the EDT
        frame.setVisible(true);

        // standard SWT dispatch loop
        while(!swtShell.isDisposed())
        {
            if(!display.readAndDispatch())
                display.sleep();
        }
        swtShell.dispose();
    }
}

This compiles fine, but when I run it as application in Eclipse, I get the following error:

Exception in thread “main”
java.lang.UnsatisfiedLinkError:
sun.awt.SunToolkit.getAppContext(Ljava/lang/Object;)Lsun/awt/AppContext;
at
sun.awt.SunToolkit.getAppContext(Native
Method) at
sun.awt.SunToolkit.targetToAppContext(Unknown
Source) at
sun.awt.windows.WComponentPeer.postEvent(Unknown
Source) at
sun.awt.windows.WComponentPeer.postPaintIfNecessary(Unknown
Source) at
sun.awt.windows.WComponentPeer.handlePaint(Unknown
Source) at
sun.java2d.d3d.D3DScreenUpdateManager.repaintPeerTarget(Unknown
Source) at
sun.java2d.d3d.D3DScreenUpdateManager.createScreenSurface(Unknown
Source) at
sun.awt.windows.WComponentPeer.replaceSurfaceData(Unknown
Source) at
sun.awt.windows.WComponentPeer.replaceSurfaceData(Unknown
Source) at
sun.awt.windows.WComponentPeer.setBounds(Unknown
Source) at
sun.awt.windows.WWindowPeer.setBounds(Unknown
Source) at
sun.awt.windows.WComponentPeer.initialize(Unknown
Source) at
sun.awt.windows.WCanvasPeer.initialize(Unknown
Source) at
sun.awt.windows.WPanelPeer.initialize(Unknown
Source) at
sun.awt.windows.WWindowPeer.initialize(Unknown
Source) at
sun.awt.windows.WFramePeer.initialize(Unknown
Source) at
sun.awt.windows.WComponentPeer.(Unknown
Source) at
sun.awt.windows.WCanvasPeer.(Unknown
Source) at
sun.awt.windows.WPanelPeer.(Unknown
Source) at
sun.awt.windows.WWindowPeer.(Unknown
Source) at
sun.awt.windows.WFramePeer.(Unknown
Source) at
sun.awt.windows.WToolkit.createFrame(Unknown
Source) at
java.awt.Frame.addNotify(Unknown
Source) at
java.awt.Window.show(Unknown Source)
at java.awt.Component.show(Unknown
Source) at
java.awt.Component.setVisible(Unknown
Source) at
java.awt.Window.setVisible(Unknown
Source) at
HelloWorldSWT.main(HelloWorldSWT.java:20)

What am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T07:56:34+00:00Added an answer on May 12, 2026 at 7:56 am

    Since version 3.3, SWT automatically finds its required platform-specific libraries, which are inside the swt.jar (at the top level of the JAR contents). So all you need is swt.jar in the classpath, and it works.

    One way to get an UnsatisifiedLinkError is if you’re using a swt.jar for another platform — they’re all named “swt.jar”; for example, if you download the one for Linux, and try to use it on Windows. The project will compile OK since all the API-level code is the same Java for every platform, but it will fail when you run because the native libraries are wrong.

    However, since the error in this case happens in AWT, it might be something else, not directly related to SWT. First, make sure you’ve downloaded the Windows SWT release. When you import it into your workspace, it creates an Eclipse project named org.eclipse.swt, which contains the swt.jar. You then make org.eclipse.swt a required project for your project, and nothing else in the Build Path besides a valid, clean JRE (you can try defining a new one [Window -> Preferences -> Java -> Installed JREs], or just use a different one you might have installed).

    You can also test it from the shell/command window. Go to your project directory. The command should be as simple as:

    java -cp bin;..\org.eclipse.swt\swt.jar HelloWorldSWT
    

    I got your code to run (Vista-32, JDK 6_15), but the window opened really small, and would not close. I don’t know anything about the SWT-AWT bridge though, so good luck with that….

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am doing a simple coin flipping experiment for class that involves flipping a
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.