Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » problem creating self executable jar file
problem creating self executable jar file [message #432728] Thu, 25 March 2004 08:14 Go to next message
Eclipse UserFriend
Originally posted by: pmrityun.in.ibm.com

Hi Team members,
I am trying to create a self executable jar file for a simple SWT program
which launches a window having a text field and a button. However I am
unsuccessful at it, and need your help. The error I get is :

Exception in thread "main" java.lang.NoClassDefFoundError:
org/eclipse/swt/widgets/Composite

The steps I followed is:
1) In Eclipse I used - File -> Export -> jar...
2) Selected my java file
3) opted for "generate manifest file"
4) selected the required main class
5) tried to run from command prompt using java -jar <Filename.jar> [failed
to run]

Points to note:
1) There is problem flagged only for Composite class
2) Manual creation of jar file from Sun Java also flags the same problem
of Composite class
3) BUT, a simple Sysout program runs fine if jar created the same way
4) Classpath has been set properly to swt.jar
5) Running the class file directly from the same command prompt has no
problem.
Any help?
Thanks
-Prasad
Re: problem creating self executable jar file [message #432733 is a reply to message #432728] Thu, 25 March 2004 11:28 Go to previous message
Eclipse UserFriend
Originally posted by: friederich.kupzog.de

Hello Mrityunjay,

the problem is that the swt.jar is not found by the class loader.
(Composite is the first Class that fails to be loaded)
You will not be able to run a SWT app from a single jar unless you
include the swt.jar contents in your own jar.

What you could also do is to specify a classpath in such a way that the
class loader finds the swt jar. I was ponted to the solution in this
forum some months ago. I think the solution looked like

java -cp myClasses.jar; swt.jar de.kupzog.MyMainClass

But the problem here is that you cannot just double-click on the jar
file, you need to specify some arguments.

There should also be a possibility to specify the classpath in the
manifest file. I did not try this so far, but that could be the solution.

Hope that helped,
Friederich

Mrityunjay Prasad wrote:

> Hi Team members,
> I am trying to create a self executable jar file for a simple SWT program
> which launches a window having a text field and a button. However I am
> unsuccessful at it, and need your help. The error I get is :
>
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/eclipse/swt/widgets/Composite
>
> The steps I followed is:
> 1) In Eclipse I used - File -> Export -> jar...
> 2) Selected my java file
> 3) opted for "generate manifest file"
> 4) selected the required main class
> 5) tried to run from command prompt using java -jar <Filename.jar> [failed
> to run]
>
> Points to note:
> 1) There is problem flagged only for Composite class
> 2) Manual creation of jar file from Sun Java also flags the same problem
> of Composite class
> 3) BUT, a simple Sysout program runs fine if jar created the same way
> 4) Classpath has been set properly to swt.jar
> 5) Running the class file directly from the same command prompt has no
> problem.
> Any help?
> Thanks
> -Prasad
>


--
Friederich Kupzog
Elektronik & Software
Neusser Str. 5-7
50670 Köln
Tel 0241 160696-1
Fax 0221 726670
www.kupzog.de/fkmk
Previous Topic:Vertical alignment of text within a Label control?
Next Topic:[Off Topic] Comparing Strings
Goto Forum:
  


Current Time: Sat Nov 29 02:45:42 GMT 2014

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

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