Results 1 to 11 of 11
  1. #1
    Astralogic is offline Member
    Join Date
    Mar 2012
    Posts
    71
    Rep Power
    0

    Default Compile error :(

    Hi forum, I'm brand spanking new to Java and I've run into a compile error while following the HelloWorlSWT tutorial that comes with Eclipse.

    Here's my code, copied directly from the tutorial:

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


    Java Code:
    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();
    	}
    
    }
    And here's my error:

    Java Code:
    Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons: 
    	no swt-win32-3740 in java.library.path
    	no swt-win32 in java.library.path
    	Can't load library: C:\Users\Calvin\.swt\lib\win32\x86_64\swt-win32-3740.dll
    	Can't load library: C:\Users\Calvin\.swt\lib\win32\x86_64\swt-win32.dll
    
    	at org.eclipse.swt.internal.Library.loadLibrary(Library.java:285)
    	at org.eclipse.swt.internal.Library.loadLibrary(Library.java:194)
    	at org.eclipse.swt.internal.C.<clinit>(C.java:21)
    	at org.eclipse.swt.widgets.Display.<clinit>(Display.java:138)
    	at HelloWorldSWT.main(HelloWorldSWT.java:13)
    Clearly Eclipse expected to find something and didn't, but wouldn't everything I need come with Eclipse? I did download the JDK as well, although I read Eclipse doesn't use it.

    Thanks
    Astralogic

  2. #2
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    760
    Rep Power
    8

    Default Re: Compile error :(

    You need to have to SWT library too. You can download it here SWT: The Standard Widget Toolkit

  3. #3
    Astralogic is offline Member
    Join Date
    Mar 2012
    Posts
    71
    Rep Power
    0

    Default Re: Compile error :(

    Quote Originally Posted by wsaryada View Post
    You need to have to SWT library too. You can download it here SWT: The Standard Widget Toolkit
    Thanks Wsaryada, but I'm still a little stuck. I downloaded the SWT library but can't find much information on where I should put it. I found this in the SWT FAQ:

    Q: Why do I get the error "java.lang.UnsatisfiedLinkError: no swt-win32-3232 in java.library.path."?
    A: The SWT JNI libraries must be found at runtime. As of Eclipse/SWT 3.3 this will happen automatically if the platform-specific SWT jar is on the java classpath. For older Eclipse/SWT versions you need to place the SWT JNI libraries in a place where the Java Virtual Machine will find them.

    The SWT JNI libraries are included in the SWT download.

    A Java application can be informed of the location of the libraries in several ways:

    Set the library path in the VM launch arguments.

    In the Launch Configuration Dialog of eclipse select the Arguments page, and in the VM arguments field enter: -Djava.library.path={runtime-library-path} Where the runtime-library-path is the absolute path to the directory containing the native code library (see above).

    This solution means that the SWT libraries have to be manually added to every project that uses SWT.

    Set the library location in an environment variable.

    For Windows this is done by editing the PATH environment variable to include the above mentioned runtime-library-path.
    in Win 9X this is done by editing the autoexec.bat file,
    on NT or 2K the variable is edited through My Computer > Properties > Advanced > Environment Variables.

    On linux/unix, modify the LD_LIBRARY_PATH environment variable to include the runtime-library-path.

    Copy the SWT library to a directory that is already on the Java library path. For example, the jre/bin directory.

    The disadvantage of this solution is that every time you upgrade eclipse you have to remember to copy the native code library.

    Starting with Eclipse 3.1, the SWT plugin that comes with Eclipse, includes the JNI libraries in the SWT jar. This was done to support OSGi and Eclipse RCP. If you are using the plugin you must extract the libraries to include them in the path.

    First thing is at the bottom it says SWT is included in Eclipse, strange.
    .
    Anyway, from the above quoted text (which I find somewhat confusing) I'm led to believe that if I extract the contents of the SWT archive to my jre7/bin folder it will work, but it doesn't.

    Do you have any idea what might be wrong?

    Thanks
    Astralogic

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,658
    Blog Entries
    7
    Rep Power
    21

    Default Re: Compile error :(

    Quote Originally Posted by Astralogic View Post
    First thing is at the bottom it says SWT is included in Eclipse, strange.
    Yep, Eclipse uses SWT itself; search for your .dll and copy it somewhere where your JVM can find it (somewhere on the PATH should be fine).

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    Astralogic is offline Member
    Join Date
    Mar 2012
    Posts
    71
    Rep Power
    0

    Default Re: Compile error :(

    Thanks Josah, I copied the dll specified in the compile errors and the folder it mentioned there, and it now works :)

    Although I do get a lot of warnings:

    Description Resource Path Location Type
    Build path specifies execution environment CDC-1.0/Foundation-1.0. There are no JREs installed in the workspace that are strictly compatible with this environment. org.eclipse.swt.win32.win32.x86_64 Build path JRE System Library Problem
    The method getPeer() from the type Component is deprecated SWT_AWT.java /org.eclipse.swt.win32.win32.x86_64/src/org/eclipse/swt/awt line 196 Java Problem
    The method removeEventListener(OleAutomation, GUID, int, OleListener) from the type OleControlSite is deprecated IE.java /org.eclipse.swt.win32.win32.x86_64/src/org/eclipse/swt/browser line 1950 Java Problem
    The method removeEventListener(OleAutomation, GUID, int, OleListener) from the type OleControlSite is deprecated IE.java /org.eclipse.swt.win32.win32.x86_64/src/org/eclipse/swt/browser line 1951 Java Problem
    The method removeEventListener(OleAutomation, GUID, int, OleListener) from the type OleControlSite is deprecated IE.java /org.eclipse.swt.win32.win32.x86_64/src/org/eclipse/swt/browser line 1952 Java Problem
    The method removeEventListener(OleAutomation, GUID, int, OleListener) from the type OleControlSite is deprecated IE.java /org.eclipse.swt.win32.win32.x86_64/src/org/eclipse/swt/browser line 1953 Java Problem
    The method removeEventListener(OleAutomation, GUID, int, OleListener) from the type OleControlSite is deprecated IE.java /org.eclipse.swt.win32.win32.x86_64/src/org/eclipse/swt/browser line 1954 Java Problem
    The method removeEventListener(OleAutomation, GUID, int, OleListener) from the type OleControlSite is deprecated IE.java /org.eclipse.swt.win32.win32.x86_64/src/org/eclipse/swt/browser line 1955 Java Problem
    The method removeEventListener(OleAutomation, GUID, int, OleListener) from the type OleControlSite is deprecated IE.java /org.eclipse.swt.win32.win32.x86_64/src/org/eclipse/swt/browser line 1956 Java Problem
    The method removeEventListener(OleAutomation, GUID, int, OleListener) from the type OleControlSite is deprecated IE.java /org.eclipse.swt.win32.win32.x86_64/src/org/eclipse/swt/browser line 1957 Java Problem
    The method removeEventListener(OleAutomation, GUID, int, OleListener) from the type OleControlSite is deprecated IE.java /org.eclipse.swt.win32.win32.x86_64/src/org/eclipse/swt/browser line 1958 Java Problem
    The method removeEventListener(OleAutomation, GUID, int, OleListener) from the type OleControlSite is deprecated IE.java /org.eclipse.swt.win32.win32.x86_64/src/org/eclipse/swt/browser line 1959 Java Problem
    The method removeEventListener(OleAutomation, GUID, int, OleListener) from the type OleControlSite is deprecated IE.java /org.eclipse.swt.win32.win32.x86_64/src/org/eclipse/swt/browser line 1960 Java Problem
    The method removeEventListener(OleAutomation, GUID, int, OleListener) from the type OleControlSite is deprecated IE.java /org.eclipse.swt.win32.win32.x86_64/src/org/eclipse/swt/browser line 1961 Java Problem
    There is no 'jre.compilation.profile' build entry and the project has Java compliance preferences set build.properties /org.eclipse.swt.win32.win32.x86_64 line 1 Plug-in Problem
    Are these something I should be concerned with?

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,097
    Rep Power
    20

    Default Re: Compile error :(

    If you're brand spanking new to Java then SWT really is not the place to be starting.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  7. #7
    Astralogic is offline Member
    Join Date
    Mar 2012
    Posts
    71
    Rep Power
    0

    Default Re: Compile error :(

    Quote Originally Posted by Tolls View Post
    If you're brand spanking new to Java then SWT really is not the place to be starting.
    Oh don't worry, I have no intention of starting with SWT :) I just saw the tutorial on Eclipse's welcome screen and couldn't resist having a go.

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,097
    Rep Power
    20

    Default Re: Compile error :(

    Ah.
    Well, I would recommend starting here instead.
    :)
    That one'll get you a reasonable grounding on classpaths etc that you won't get going through an IDE.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  9. #9
    Astralogic is offline Member
    Join Date
    Mar 2012
    Posts
    71
    Rep Power
    0

    Default Re: Compile error :(

    Quote Originally Posted by Tolls View Post
    Ah.
    Well, I would recommend starting here instead.
    :)
    That one'll get you a reasonable grounding on classpaths etc that you won't get going through an IDE.
    Thanks Tolls, that site looks like a great resource

  10. #10
    kast is offline Member
    Join Date
    Jul 2013
    Posts
    1
    Rep Power
    0

    Default Re: Compile error :(

    Quote Originally Posted by Astralogic View Post
    Thanks Tolls, that site looks like a great resource
    The SWT FAQ

    you can add the swt-package as a resource to your project manually. this worked great for me in eclipse kepler release....

  11. #11
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default Re: Compile error :(

    Don't post to old dead threads. I'm closing this.

    db

    THREAD CLOSED
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. i get this error during compile
    By Bibin in forum New To Java
    Replies: 1
    Last Post: 12-24-2011, 08:43 AM
  2. compile error
    By missmara77 in forum New To Java
    Replies: 1
    Last Post: 10-31-2011, 07:48 PM
  3. compile error
    By angryredantz in forum New To Java
    Replies: 1
    Last Post: 01-23-2009, 10:44 PM
  4. Compile Error - Please Help!!
    By AJ2009 in forum New To Java
    Replies: 10
    Last Post: 01-04-2009, 03:59 PM
  5. compile error
    By dirtycash in forum New To Java
    Replies: 6
    Last Post: 12-12-2007, 06:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •