• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

I can compile SWT out of eclipse but not in Eclipse :)

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By command line I can compile and run successfully
javac.exe -classpath "C:\SWT\swt.jar";. HelloWorld.java
java.exe -classpath "C:\SWT\swt.jar";. -Djava.library.path=C:\SWT HelloWorld

Under Eclipse I have added swt.jar in Java Build Path and classpath and
-Djava.library.path=C:\SWT in Run/Run... menu but I got this error why ? I thought using an IDE was supposed to make things easier than commandline

java.lang.UnsatisfiedLinkError: no swt-win32-3062 in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1517)
at java.lang.Runtime.loadLibrary0(Runtime.java:788)
at java.lang.System.loadLibrary(System.java:834)
at org.eclipse.swt.internal.Library.loadLibrary(Library.java:100)
at org.eclipse.swt.internal.win32.OS.<clinit>(OS.java:18)
at org.eclipse.swt.graphics.Device.init(Device.java:564)
at org.eclipse.swt.widgets.Display.init(Display.java:1780)
at org.eclipse.swt.graphics.Device.<init>(Device.java:100)
at org.eclipse.swt.widgets.Display.<init>(Display.java:355)
at org.eclipse.swt.widgets.Display.<init>(Display.java:351)
at HelloWorld.main(HelloWorld.java:20)
Exception in thread "main"

[ May 15, 2005: Message edited by: albert lone ]
[ May 15, 2005: Message edited by: albert lone ]
 
albert lone
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nobody seems to know here

Where can I ask the question ? I know there is a Eclipse newsgroup but I hate Newsgroup it's always full of hackers because your IP address is in clear.
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are the .dll files also under C:\SWT?
 
author
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As Gregg mentioned, your library path must point to the directory that contains the swt dll files. Alternatively you can put them your windows\system32 directory. This will make them globally available without specifying the library path. I wouldn't recommend this option however.

Scott Delap
ClientJava.com
Desktop Java Live
 
albert lone
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have first tried to use the SWT of eclipse IDE by following their welcome tutorial:
- added C:\eclipse 3.1M4\plugins\org.eclipse.swt.win32_3.1.0\ws\win32\swt.jar to the libraries
- added -Djava.library.path=${system:ECLIPSE_HOME}/plugins/org.eclipse.swt.${system:WS}_3.1.0/os/${system S}/${system:ARCH}
to VM arguments

I got this error message:
-----------------------------------------------------------
java.lang.NoClassDefFoundError: 3/1M4/plugins/org/eclipse/swt/win32_3/1/0/os/win32/x86
Exception in thread "main"
-----------------------------------------------------------

that's why I finally downloaded SWT separately and unzip it in c:\SWT and there are 2 dlls inside:

swt-win32-3062.dll
swt-awt-win32-3062.dll
[ May 16, 2005: Message edited by: albert lone ]
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Move those DLL's to Windows/System32 and see if it works then. That way we can narrow down the problem to something else.
 
albert lone
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have made a mistake: I have added swt.jar to the classpath Bootstrap entries and it caused the messages error above.

Now the error error message that subsist is much shorter:
--------------------------------------------------------------
java.lang.NoClassDefFoundError: org/eclipse/swt/widgets/Display
at HelloWorld.main(HelloWorld.java:22)
Exception in thread "main"
--------------------------------------------------------------
isn't it a classpath error ?
I have checked that I added c:\swt.jar to the project libraries what else does it want Java classpath is the most horrible invention .
---------------------------------------------------------------
I give the source of the program in case it's usefull:

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

public class HelloWorld {

public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
Label label = new Label(shell, SWT.NONE);
label.setText("Hello, World!");
shell.pack();
label.pack();
shell.open();
while(!shell.isDisposed())
if (!display.readAndDispatch())
display.sleep();
display.dispose();
label.dispose();
}
}
 
albert lone
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is said here:

http://www.klomp.org/mark/classpath/doc/api/html/java/lang/NoClassDefFoundError.html

"A NoClassDefFoundError is thrown when a classloader or the Java Virtual Machine tries to load a class and no definition of the class can be found. This could happen when using the new expression or during a normal method call. The reason this would occur at runtime is because the missing class definition existed when the currently executing class was compiled, but now that definition cannot be found. "


OK but why on earth Eclipse says the import is OK but when it runs it doesn't find org/eclipse/swt/widgets/Display ?

This is really driving me crazy and the only reason why I'm going to switch to C# if this kind of stupid problem cannot be solved that's kind of detail that hurts Java but evil is in the details
[ May 18, 2005: Message edited by: albert lone ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic