Results 1 to 9 of 9
Thread: Compile error :(
- 03-26-2012, 11:16 PM #1
Member
- Join Date
- Mar 2012
- Posts
- 71
- Rep Power
- 0
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;
And here's my error: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(); } }
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.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)
Thanks
Astralogic
- 03-27-2012, 03:24 AM #2
Senior Member
- Join Date
- Jun 2007
- Location
- Bali, Indonesia
- Posts
- 696
- Rep Power
- 6
Re: Compile error :(
You need to have to SWT library too. You can download it here SWT: The Standard Widget Toolkit
Website: Learn Java by Examples
- 03-27-2012, 11:13 AM #3
Member
- Join Date
- Mar 2012
- Posts
- 71
- Rep Power
- 0
Re: Compile error :(
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
- 03-27-2012, 11:29 AM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,406
- Blog Entries
- 7
- Rep Power
- 17
- 03-27-2012, 11:45 AM #5
Member
- Join Date
- Mar 2012
- Posts
- 71
- Rep Power
- 0
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:
Are these something I should be concerned with?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
- 03-27-2012, 11:59 AM #6
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
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.
- 03-27-2012, 12:26 PM #7
Member
- Join Date
- Mar 2012
- Posts
- 71
- Rep Power
- 0
- 03-27-2012, 12:40 PM #8
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
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.
- 03-27-2012, 11:21 PM #9
Member
- Join Date
- Mar 2012
- Posts
- 71
- Rep Power
- 0
Similar Threads
-
i get this error during compile
By Bibin in forum New To JavaReplies: 1Last Post: 12-24-2011, 08:43 AM -
compile error
By missmara77 in forum New To JavaReplies: 1Last Post: 10-31-2011, 07:48 PM -
compile error
By angryredantz in forum New To JavaReplies: 1Last Post: 01-23-2009, 10:44 PM -
Compile Error - Please Help!!
By AJ2009 in forum New To JavaReplies: 10Last Post: 01-04-2009, 03:59 PM -
compile error
By dirtycash in forum New To JavaReplies: 6Last Post: 12-12-2007, 06:00 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks