Home » Newcomers » Newcomers » Getting standalone program to run with SWT
Getting standalone program to run with SWT [message #106650] |
Sun, 02 October 2005 07:31  |
Eclipse User |
|
|
|
Originally posted by: eclipse.ptoye.com
I posted this in the SWT section but haven't had any response - maybe it's
too elementary a question for the SWT gurus so I'll try here.
Another silly newbie question, this time about how to build a JAR file for
a standalone SWT prog.
I tried using the File|Export wizard, included org.eclipse.swt as a
resource and told it to generate a manifest. It generated OK (with a
complaint that .classpath and .project were duplicated) but when I run it
from a command line I get
>java -jar PartSWT.jar
Exception in thread "main" java.lang.NoClassDefFoundError:
org/eclipse/swt/events/SelectionListener
at java.lang.ClassLoader.defineClass1(Native Method)
.
.
.
I suspect that the problem is in the manifest, but AFAICS the help files
don't tell you what to put in there (just the syntax) and the books I've
got are too elementary to be of use.
There are really two questions:
1) What should I change manually to get it to work?
2) Is it an Eclipse bug that the automatic generation doesn't work?
The manifest and jardesc files follow.
Peter
The MANIFEST.MF file in the JAR file says:
Manifest-Version: 1.0
Class-Path: swt.jar
Main-Class: com.ptoye.partSWT.GeneratePartitions
The JAR description file says:
<?xml version="1.0" encoding="UTF-8"?>
<jardesc>
<jar path="D:/Peter/Java/PartitionSWT/PartSWT.jar"/>
<options buildIfNeeded="true" compress="true"
descriptionLocation="/PartitionSWT/PartSWT.jardesc" exportErrors="true"
exportWarnings="true" includeDirectoryEntries="false" overwrite="false"
saveDescription="true" useSourceFolders="false"/>
<manifest generateManifest="false"
mainClassHandleIdentifier="=PartitionSWT/<com.ptoye.partSWT
{GeneratePartitions.java[GeneratePartitions"
manifestLocation="/PartitionSWT/PartSWT.mf" manifestVersion="1.0"
reuseManifest="true" saveManifest="true" usesManifest="true">
<sealing sealJar="false">
<packagesToSeal/>
<packagesToUnSeal/>
</sealing>
</manifest>
<selectedElements exportClassFiles="true" exportJavaFiles="false"
exportOutputFolder="false">
<javaElement handleIdentifier="=org.eclipse.swt"/>
<javaElement handleIdentifier="=PartitionSWT/<com.ptoye.partSWT"/ >
</selectedElements>
</jardesc>
|
|
| |
Re: Getting standalone program to run with SWT [message #107428 is a reply to message #107276] |
Wed, 05 October 2005 09:40   |
Eclipse User |
|
|
|
Originally posted by: eclipse.ptoye.com
In article <9c865cd055a8c797b72ed1fc80@news.eclipse.org>,
g_zielinski@intechion.pl (=?utf-8?Q?Grzegorz=20Zieli=c5=84ski?=) wrote:
> *From:* Grzegorz Zieliński<g_zielinski@intechion.pl>
> *Date:* Wed, 5 Oct 2005 09:29:25 +0000 (UTC)
>
> Hello Peter,
>
> > I posted this in the SWT section but haven't had any response - maybe
> > it's too elementary a question for the SWT gurus so I'll try here.
> >
> > Another silly newbie question, this time about how to build a JAR file
> > for a standalone SWT prog.
> >
> > I tried using the File|Export wizard, included org.eclipse.swt as a
> > resource and told it to generate a manifest. It generated OK (with a
> > complaint that .classpath and .project were duplicated) but when I run
> > it from a command line I get
> >
> >> java -jar PartSWT.jar
> >>
> > Exception in thread "main" java.lang.NoClassDefFoundError:
> > org/eclipse/swt/events/SelectionListener
> > at java.lang.ClassLoader.defineClass1(Native Method)
> > .
> > .
> > .
> > I suspect that the problem is in the manifest, but AFAICS the help
> > files don't tell you what to put in there (just the syntax) and the
> > books I've got are too elementary to be of use.
> >
> > There are really two questions:
> >
> > 1) What should I change manually to get it to work?
> >
> > 2) Is it an Eclipse bug that the automatic generation doesn't work?
> >
>
> I had similar problem. And not only me... :) Here is link to similar
> problem's solution:
> http://dev.eclipse.org/newslists/news.eclipse.platform.swt/m sg21900.html
> I hope this will answer all your question. If not - don't hesitate to
> ask...
>
> Sincerely
>
> GregZiel
>
>
>
Thanks Greg, I'll try it out - when I have time!
I thought the idea of Eclipse and wizards was that they did the work for
you. It seems that this is not the case, or that the Eclipse project is
severely buggy and lacking in proper documentation. Thank heavens for
newsgroups and chat boards. Meanwhile, this is driving me back to Visual
Basic (spit).
Peter
|
|
|
Re: Getting standalone program to run with SWT [message #107467 is a reply to message #107428] |
Wed, 05 October 2005 10:02   |
Eclipse User |
|
|
|
Hello Peter,
> Thanks Greg, I'll try it out - when I have time!
>
> I thought the idea of Eclipse and wizards was that they did the work
> for you. It seems that this is not the case, or that the Eclipse
> project is severely buggy and lacking in proper documentation. Thank
> heavens for newsgroups and chat boards. Meanwhile, this is driving me
> back to Visual Basic (spit).
>
> Peter
>
Don't give up so soon! The article (or rather discussion) in the link above
may seem to be complicated, but the solution is realy easy:
1. Create folder for your application deployment
2. Create "lib" subfolder
3. Copy all necessary jars into "lib" folder
4. Update manifest file
5. Create *.jar archive using manifest from 4.
6. Copy *.jar into folder from 1.
Voila! Everything works ok. Next time you'll change something in application,
it won't be necessary to repeat all steps - only steps 5 and 6, just like
it should
be.
And here is my manifest file:
----------
Manifest-Version: 1.0
Main-Class: com.intechion.wdgvco.main.App
Class-Path: lib\org.eclipse.swt.win32.win32.x86_3.1.0.jar lib\org.eclipse.jface_3.1.0.jar
lib\org.eclipse.jface.text_3.1.0.jar lib\org.eclipse.core.runtime_3.1.0.jar
lib\org.eclipse.core.runtime.compatibility_3.1.0.jar lib\org.eclipse.osgi_3.1.0.jar
lib\org.eclipse.core.commands_3.1.0.jar
----------
Copy this as your manifest, only changing Main-Class declaration. This also
shows which libraries should be copied.
Only remember to create "Class-Path" as single line.
As for VisualBasic - it's cool tool, although I'd rather use C#. But there
is one catch - the price. It's "a bit" expensive
tool, while Eclipse and Java are free... :)
Regards
Grzegorz Zieliński
g_zielinski<at>intechion.pl
|
|
|
Re: Getting standalone program to run with SWT [message #107731 is a reply to message #107467] |
Thu, 06 October 2005 04:19   |
Eclipse User |
|
|
|
Originally posted by: eclipse.ptoye.com
In article <9c865cd0a2e8c797dd48b295c0@news.eclipse.org>,
g_zielinski@intechion.pl (=?utf-8?Q?Grzegorz=20Zieli=c5=84ski?=) wrote:
> *From:* Grzegorz Zieliński<g_zielinski@intechion.pl>
> *Date:* Wed, 5 Oct 2005 14:02:09 +0000 (UTC)
>
> Hello Peter,
>
> > Thanks Greg, I'll try it out - when I have time!
> >
> > I thought the idea of Eclipse and wizards was that they did the work
> > for you. It seems that this is not the case, or that the Eclipse
> > project is severely buggy and lacking in proper documentation. Thank
> > heavens for newsgroups and chat boards. Meanwhile, this is driving me
> > back to Visual Basic (spit).
> >
> > Peter
> >
>
> Don't give up so soon! The article (or rather discussion) in the link
> above may seem to be complicated, but the solution is realy easy:
> 1. Create folder for your application deployment
> 2. Create "lib" subfolder
> 3. Copy all necessary jars into "lib" folder
> 4. Update manifest file
> 5. Create *.jar archive using manifest from 4.
> 6. Copy *.jar into folder from 1.
> Voila! Everything works ok. Next time you'll change something in
> application,
>
> it won't be necessary to repeat all steps - only steps 5 and 6, just
> like it should be.
>
> And here is my manifest file:
>
> ----------
> Manifest-Version: 1.0
> Main-Class: com.intechion.wdgvco.main.App
> Class-Path: lib\org.eclipse.swt.win32.win32.x86_3.1.0.jar
> lib\org.eclipse.jface_3.1.0.jar lib\org.eclipse.jface.text_3.1.0.jar
> lib\org.eclipse.core.runtime_3.1.0.jar
> lib\org.eclipse.core.runtime.compatibility_3.1.0.jar
> lib\org.eclipse.osgi_3.1.0.jar lib\org.eclipse.core.commands_3.1.0.jar
> ----------
>
> Copy this as your manifest, only changing Main-Class declaration. This
> also shows which libraries should be copied. Only remember to create
> "Class-Path" as single line.
>
> As for VisualBasic - it's cool tool, although I'd rather use C#. But
> there is one catch - the price. It's "a bit" expensive tool, while
> Eclipse and Java are free... :)
>
> Regards
>
> Grzegorz Zieliński
> g_zielinski<at>intechion.pl
>
>
>
Greg,
I'm not giving up quite yet! What I was hoping was that Eclipse would
offer me a quick way into learning Java (a new language for me - I started
computing 40 years ago and am a bit old-fashioned). But when it becomes
almost impossible to find out what's needed to run a relatively simple
program, it's a bit discouraging. The sort of information that you're very
kindly giving me really should be in the documentation or on a FAQ site -
the Eclipse project does itself no favours this way.
And VB isn't expensive - the new beta (without all the documentation but
with a very active forum) is free until next year. Ditto C# and C++ (all
..NET of course). And I was able to run the same program that I'm having
all the trouble with in half the time.
Or maybe I should use awt & swing rather than SWT for my UI?
Peter
|
|
|
Re: Getting standalone program to run with SWT [message #107759 is a reply to message #107731] |
Thu, 06 October 2005 05:53   |
Eclipse User |
|
|
|
Hello Peter,
> I'm not giving up quite yet! What I was hoping was that Eclipse would
> offer me a quick way into learning Java (a new language for me - I
> started computing 40 years ago and am a bit old-fashioned). But when
> it becomes almost impossible to find out what's needed to run a
> relatively simple program, it's a bit discouraging. The sort of
> information that you're very kindly giving me really should be in the
> documentation or on a FAQ site - the Eclipse project does itself no
> favours this way.
>
> And VB isn't expensive - the new beta (without all the documentation
> but with a very active forum) is free until next year. Ditto C# and
> C++ (all .NET of course). And I was able to run the same program that
> I'm having all the trouble with in half the time.
>
> Or maybe I should use awt & swing rather than SWT for my UI?
>
> Peter
>
I agree, that documentation for Eclipse and SWT/JFace cries for updates
and improvements.
If you're new on the Java side of Power, you may try starting with Swing,
which is much better documented (see Sun's Java Tutorial). SWT/JFace
are pretty new libraries, and even their API is a bit unstable, not mentioning
documentation.
As for VB 2005 beta - I would think twice before switching to this side of
power... :)
I don't have Microsoftphoby - in fact I've spent lots of time creating solutions
in VB .NET and C# .NET and I like both these languages and this IDE. But
using
beta version in commercial application would be too bravery for me... :) not
mentioning the licence - I'm not sure the beta version of .NET allows writing
AND selling commercial applications. Moreover - the "beta" word means something.
You can't expect that everything will work right and will be properly and
precisely
described. But on the MS side you won't have access to source code, so you
won't
be able to find what's wrong. And Java actually gives you this opportunity.
For
example, I had problem with JTextPane component (it's Swing component, but
I had for some reasons to use it in an SWT app) - displaying HTML required
images to be stored in some place accessible via URL, so on local disc or
on some
remote storage. But I wanted to store them in my app's objects, without
hard disc mediation. And I have it up and working - a bit of debugging and
I managed to force alternative images source via imageCache property... :)
"Brand matters not. Stay on the light (err... I meant Java) side, you must."
;)
Grzegorz Zieliński
g_zielinski<at>intechion.pl
|
|
|
Re: Getting standalone program to run with SWT [message #107771 is a reply to message #107759] |
Thu, 06 October 2005 08:08  |
Eclipse User |
|
|
|
Originally posted by: eclipse.ptoye.com
In article <9c865cd0c758c79883c3f04650@news.eclipse.org>,
g_zielinski@intechion.pl (=?utf-8?Q?Grzegorz=20Zieli=c5=84ski?=) wrote:
> *From:* Grzegorz Zieliński<g_zielinski@intechion.pl>
> *Date:* Thu, 6 Oct 2005 09:53:51 +0000 (UTC)
>
> Hello Peter,
>
> > I'm not giving up quite yet! What I was hoping was that Eclipse would
> > offer me a quick way into learning Java (a new language for me - I
> > started computing 40 years ago and am a bit old-fashioned). But when
> > it becomes almost impossible to find out what's needed to run a
> > relatively simple program, it's a bit discouraging. The sort of
> > information that you're very kindly giving me really should be in the
> > documentation or on a FAQ site - the Eclipse project does itself no
> > favours this way.
> >
> > And VB isn't expensive - the new beta (without all the documentation
> > but with a very active forum) is free until next year. Ditto C# and
> > C++ (all .NET of course). And I was able to run the same program that
> > I'm having all the trouble with in half the time.
> >
> > Or maybe I should use awt & swing rather than SWT for my UI?
> >
> > Peter
> >
>
> I agree, that documentation for Eclipse and SWT/JFace cries for updates
> and improvements.
> If you're new on the Java side of Power, you may try starting with
> Swing, which is much better documented (see Sun's Java Tutorial).
> SWT/JFace are pretty new libraries, and even their API is a bit
> unstable, not mentioning
>
> documentation.
> As for VB 2005 beta - I would think twice before switching to this side
> of power... :) I don't have Microsoftphoby - in fact I've spent lots of
> time creating solutions
>
> in VB .NET and C# .NET and I like both these languages and this IDE.
> But using beta version in commercial application would be too bravery
> for me... :) not mentioning the licence - I'm not sure the beta version
> of .NET allows writing
>
> AND selling commercial applications. Moreover - the "beta" word means
> something.
>
> You can't expect that everything will work right and will be properly
> and precisely described. But on the MS side you won't have access to
> source code, so you won't be able to find what's wrong. And Java
> actually gives you this opportunity. For example, I had problem with
> JTextPane component (it's Swing component, but I had for some reasons
> to use it in an SWT app) - displaying HTML required images to be stored
> in some place accessible via URL, so on local disc or on some remote
> storage. But I wanted to store them in my app's objects, without hard
> disc mediation. And I have it up and working - a bit of debugging and
> I managed to force alternative images source via imageCache property...
> :)
>
> "Brand matters not. Stay on the light (err... I meant Java) side, you
> must." ;)
>
>
> Grzegorz Zieliński
> g_zielinski<at>intechion.pl
>
>
>
Greg,
I'm only writing odd programs for my amusement (playing Sudoku at the
moment) so the beta licence isn't an issue. And thought that I'd play with
Java as well, but finding it much more of an uphill struggle (I don't want
actually to BUY any books for a fringe hobby, so am reliant on the public
library (out of date mostly) and the online documentation).
Peter
|
|
|
Goto Forum:
Current Time: Fri May 09 13:06:13 EDT 2025
Powered by FUDForum. Page generated in 0.08995 seconds
|