Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Problems with the tutorial HelloWorldSWT
Problems with the tutorial HelloWorldSWT [message #755934] Thu, 10 November 2011 09:09 Go to next message
Virgilio Ravagli is currently offline Virgilio RavagliFriend
Messages: 12
Registered: November 2011
Junior Member
After a while and some pain, I was able to make the tutorial HelloWorldSWT working on my PC, not only inside Eclipse (doing Run as-->Java app) but even as a standalone jarfile.

But I've got a lot of doubts about the "quality" of my solution.

I use Eclipse Indigo for Java Developer, with Window Builder, Swing and SWT Designer installed. The OS is Windows 7 Pro, both development and production.

I use ANT 1.8.1, inside Eclipse, to build the app.

So, this is my final build.xml (I also enclose it, in the case it's more readable):
<project name="HelloWorldSWT" basedir="." default="main">
<property environment="env" />
<property name="dest.dir" value="build" />
<property name="dest.dir.classes" value="${dest.dir}/classes" />
<property name="plugins.dir" value="${env.ECLIPSE_HOME}/plugins" />
<property name="repository.path" value="C:\ExeJar" />
<path id="build.class.path">
<fileset dir="${plugins.dir}">
<include name="*.jar" />
</fileset>
</path>
<target name="clean">
<delete dir="${dest.dir}" />
</target>
<target name="prepare">
<mkdir dir="${dest.dir}" />
<mkdir dir="${dest.dir.classes}" />
</target>
<target name="main" depends="clean,prepare">
<javac srcdir="src" destdir="${dest.dir.classes}" includes="app/**">
<classpath refid="build.class.path" />
</javac>
<jar manifest="mainClass.txt" duplicate="preserve"
destfile="${dest.dir}/HelloWorldSWT.jar">
<zipfileset excludes="META-INF/**/*"
src="${plugins.dir}/org.eclipse.swt.win32.win32.x86_3.7.0.v3735b.jar" />
<fileset dir="${dest.dir.classes}"/>
</jar>
<copy file="${dest.dir}/HelloWorldSWT.jar"
tofile="${repository.path}/HelloWorldSWT.jar" overwrite="true" />
</target>
</project>

It works, but I ask, is it the right way or is it a devious path ?
First of all, I'm not at ease with the inclusion of the plugin jar.

What do you suggest ?
thanks in advance,
Virgilio
  • Attachment: build.xml
    (Size: 1.20KB, Downloaded 204 times)
Re: Problems with the tutorial HelloWorldSWT [message #756041 is a reply to message #755934] Thu, 10 November 2011 15:26 Go to previous messageGo to next message
Lakshmi P ShanmugamFriend
Messages: 279
Registered: July 2009
Location: India
Senior Member
Hi,

Did you try to use/follow the "create Hello World SWT application" cheatsheet (Help>Cheatsheets)? Does it not work for you? What is the error you get?


Lakshmi P Shanmugam
Re: Problems with the tutorial HelloWorldSWT [message #756059 is a reply to message #756041] Thu, 10 November 2011 17:26 Go to previous messageGo to next message
Virgilio Ravagli is currently offline Virgilio RavagliFriend
Messages: 12
Registered: November 2011
Junior Member
Hi Lakshmi.
I followed the cheatsheet.
But the tutorial doesn't explain how to build the standalone jar, it ends with the run inside Eclipse IDE (Run as-->Java app).
I wanted to build a self-consistent jar, HelloWorldSWT.jar.
So I wrote build.xml, an ANT command file; I enclosed it in the previous mail. I put the build into my Eclipse project.
I found a trouble, because in the first version I didn't excluded SWT.jar's META-INF in the <zipfileset> clause of my build file.
First question: why do I have to exclude any META-INF ? Perhaps it's due to security reason ?

Well, after that I was able to generate my jar and it works as expected.

My second question is: in build.xml, I reference directly the plugin jar; is it correct ? is it a good practice ?
In other words: you're certainly craft in using Eclipse and SWT, on the contrary I'm a beginner; how would you build the jar (using an ANT build file, that's a must for me) ?
Bye
Virgilio
Re: Problems with the tutorial HelloWorldSWT [message #756163 is a reply to message #755934] Fri, 11 November 2011 10:41 Go to previous messageGo to next message
Thomas Singer is currently offline Thomas SingerFriend
Messages: 75
Registered: July 2009
Member
Using SWT for a standalone application is no rocket-science. Just add the platform-specific swt.jar to your application's classpath - like any other library.
Re: Problems with the tutorial HelloWorldSWT [message #781125 is a reply to message #755934] Fri, 20 January 2012 16:03 Go to previous message
Virgilio Ravagli is currently offline Virgilio RavagliFriend
Messages: 12
Registered: November 2011
Junior Member
Thomas, I do hope using SWT is not rocket science, because rocket science hangs to the ancient Chinese principles Smile. Surely, SWT is more innovative.

When you speaks about the platform specific swt.jar, are you referring to org.eclipse.swt.win32.win32.x86_3.7.0.v3735b.jar (I'm using it) ?
Or are you referring to another JAR, more general, not related to Eclipse ?

Bye,
Virgilio
Previous Topic:Add WindowBuilder TabItem at Runtime
Next Topic:Canvas overlaying Shell
Goto Forum:
  


Current Time: Tue Mar 19 10:34:58 GMT 2024

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

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

Back to the top