Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Newbie question for developing with SWT
Newbie question for developing with SWT [message #458982] Thu, 28 July 2005 08:31 Go to next message
Andrea is currently offline AndreaFriend
Messages: 27
Registered: July 2009
Junior Member
Hi, I have the Eclipse 3.0 installed on my Windows 2000. Since the
Eclipse IDE is a bit heavy and slow on my PC and since my interest is
only to learn and use SWT, I am trying to use SWT outside the IDE.

I have written a simple java source code (the classic 'Hello world')
using SWT and I have also written manually an Ant build.xml file (I am
not expert about Ant but I know how to use it).

Compilation works fine and, at the end, I have a testswt.jar file. But
when I run the application (with "java -jar testswt.jar") I get the
following error:

Exception in thread "main" java.lang.NoClassDefFoundError:
org/eclipse/swt/widgets/Display
at TestSwt.main(TestSwt.java:9)

Note (this is important!) that I have added to the %CLASSPATH% variable,
the path
" C:\Programmi2\Java\eclipse\plugins\org.eclipse.swt.win32_3.0 .2\ws\win32\swt.jar "
and I have also added to the %PATH% variable the path
" C:\Programmi2\Java\eclipse\plugins\org.eclipse.swt.win32_3.0 .2\os\win32\x86 "
where there are DLLs files for SWT.

I am using Sun JDK 1.4 (build 1.4.2_08-b03) and Ant 1.6.4.

What is wrong? Should I add other things?
Thanks in advance!
Re: Newbie question for developing with SWT [message #458988 is a reply to message #458982] Thu, 28 July 2005 13:24 Go to previous messageGo to next message
kiran is currently offline kiranFriend
Messages: 15
Registered: July 2009
Junior Member
I have used following libraries with my standalone application using SWT.

osgi.jar
resolver.jar
resources.jar
runtime.jar
swt.jar
text.jar
texteditor.jar
ui.jar
views.jar
workbench.jar
console.jar
core.jar
defaultAdaptor.jar
eclipseAdaptor.jar
editors.jar
filebuffers.jar
forms.jar
ide.jar
jface.jar
jfacetext.jar

put these libraries(all or subset) in your classpath according to your
requirements.
Re: Newbie question for developing with SWT [message #459020 is a reply to message #458982] Thu, 28 July 2005 15:04 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: hcs33.egon.gyaloglo.hu

Hi,

When you run your application with java -jar, all external classpath
settings are ignored. Either try to run with
java -classpath %CLASSPATH%;testswt.jar" your.main.class.File
or specify all 3rdparty jars in the manifest file of your jar. See
http://java.sun.com/j2se/1.4.2/docs/guide/jar/jar.html#JAR%2 0Manifest (url
may wrap) for details on jar manifests.

HTH,
Regards,
Csaba

Andrea wrote:
> Hi, I have the Eclipse 3.0 installed on my Windows 2000. Since the
> Eclipse IDE is a bit heavy and slow on my PC and since my interest is
> only to learn and use SWT, I am trying to use SWT outside the IDE.
>
> I have written a simple java source code (the classic 'Hello world')
> using SWT and I have also written manually an Ant build.xml file (I am
> not expert about Ant but I know how to use it).
>
> Compilation works fine and, at the end, I have a testswt.jar file. But
> when I run the application (with "java -jar testswt.jar") I get the
> following error:
>
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/eclipse/swt/widgets/Display
> at TestSwt.main(TestSwt.java:9)
>
> Note (this is important!) that I have added to the %CLASSPATH% variable,
> the path
>
" C:\Programmi2\Java\eclipse\plugins\org.eclipse.swt.win32_3.0 .2\ws\win32\swt
..jar"
> and I have also added to the %PATH% variable the path
>
" C:\Programmi2\Java\eclipse\plugins\org.eclipse.swt.win32_3.0 .2\os\win32\x86
"
> where there are DLLs files for SWT.
>
> I am using Sun JDK 1.4 (build 1.4.2_08-b03) and Ant 1.6.4.
>
> What is wrong? Should I add other things?
> Thanks in advance!
Re: Newbie question for developing with SWT [message #459021 is a reply to message #459020] Thu, 28 July 2005 15:56 Go to previous message
Andrea is currently offline AndreaFriend
Messages: 27
Registered: July 2009
Junior Member
Horváth, Csaba wrote:
> When you run your application with java -jar, all external classpath
> settings are ignored. Either try to run with
> java -classpath %CLASSPATH%;testswt.jar" your.main.class.File
> or specify all 3rdparty jars in the manifest file of your jar. See
> http://java.sun.com/j2se/1.4.2/docs/guide/jar/jar.html#JAR%2 0Manifest (url
> may wrap) for details on jar manifests.

Yes, it's true! After some searches, I have reached the same conclusion.

I have also found a notice in the official documentation (from Sun)
about the -jar option of java tool.
It states that:

"When you use this option, the JAR file is the source of all user
classes, and other user class path settings are ignored."

So, adding my jar to the classpath and specifing directly the main
class, it works fine. Thanks.

P.S.: IMHO, it is not a good thing to specify other jars in the manifest.
Previous Topic:How to add a column to a tableviewer ?
Next Topic:Tree and TreeColumn help
Goto Forum:
  


Current Time: Wed Oct 28 03:53:19 GMT 2020

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

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

Back to the top