|Re: Newbie question for developing with SWT [message #459020 is a reply to message #458982]
||Thu, 28 July 2005 15:04
Originally posted by: hcs33.egon.gyaloglo.hu|
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.
> 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:
> 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
> 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
Registered: July 2009
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.
Powered by FUDForum
. Page generated in 0.01634 seconds