Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » What should stay and what should go for packaging a lighter SWT JAR.
What should stay and what should go for packaging a lighter SWT JAR. [message #647208] Wed, 05 January 2011 02:24 Go to next message
Aaron Cohen is currently offline Aaron CohenFriend
Messages: 21
Registered: July 2009
Junior Member
Hello, I am writing a very small application and do not want to include
the entire SWT jar due to size concerns. I was thinking of removing
classes that I don't want from the jar but I am concerned about breaking
dependencies. If I want to only use a few classes from the jar, what
process should I follow to determine what files to keep and what to
remove? Should I build SWT from source?

Thank you!

--
Aaron
Re: What should stay and what should go for packaging a lighter SWT JAR. [message #647705 is a reply to message #647208] Fri, 07 January 2011 21:36 Go to previous message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Hi Aaron,

Building from source is the safest way to go, since deleting a required
class will give you an immediate compile error, rather than a lurking
ClassNotFound at runtime that could have an obscure trigger. You should do
something like the following:

1. Retrieve swt from cvs and rename .classpath_<platform> to .classpath:
http://www.eclipse.org/swt/cvs.php
2. Open the .classpath file and remove its packages from bottom->top (unless
you're using some of them of course). For example, for a basic app on win32
that shows some typical widgets I was able to remove all of the following
without problem (you likely won't be able to remove more than these):
<classpathentry kind="src" path="Eclipse SWT AWT/win32"/>
<classpathentry kind="src" path="Eclipse SWT AWT/common"/>
<classpathentry kind="src" path="Eclipse SWT Drag and Drop/win32"/>
<classpathentry kind="src" path="Eclipse SWT Drag and Drop/common"/>
<classpathentry kind="src" path="Eclipse SWT Printing/win32"/>
<classpathentry kind="src" path="Eclipse SWT Printing/common"/>
<classpathentry kind="src" path="Eclipse SWT Program/win32"/>
<classpathentry kind="src" path="Eclipse SWT Program/common"/>
<classpathentry kind="src" path="Eclipse SWT Custom Widgets/common"/>
<classpathentry kind="src" path="Eclipse SWT Browser/common"/>
<classpathentry kind="src" path="Eclipse SWT Browser/win32"/>
<classpathentry kind="src" path="Eclipse SWT Mozilla/common"/>
<classpathentry kind="src" path="Eclipse SWT Mozilla/win32"/>
<classpathentry kind="src" path="Eclipse SWT OpenGL/win32"/>
<classpathentry kind="src" path="Eclipse SWT OpenGL/common"/>
<classpathentry kind="src" path="Eclipse SWT Theme/win32"/>
3. You may or may not wish to go through the remaining packages and
selectively delete unneeded classes.
4. Open the org.eclipse.swt project's buildFragment.xml file and find the
copy.<platform>.src target for your platform.
5. Remove the set of <fileset> tags corresponding to the packages that you
were able to remove in step 2. These tags are what the jar compiler goes
by, not the .classpath file.
6. In the org.eclipse.swt.<ws>.<os>.<arch> fragment find the build.xml file
and run it as an Ant Build with target "swtdownload" (on the launch config's
JRE tab ensure that "Run in the Same JRE as the Workspace" is selected,
which is not the default).
7. When the Ant build has finished, refresh the
org.eclipse.swt.<ws>.<os>.<arch> fragment and you'll have a
swt-${buildid}-win32-win32-x86.zip file containing swt.jar and
swt-debug.jar. They're equivalent, but the first one is smaller because it
does not contain debug info. Pick whichever makes sense for you.
8. You can reduce your final jar a bit more by removing the swt libraries
from it that aren't needed. For example, a basic swt app on win32 only
needs the swt-win32-XXXX.dll.

If a step does not work for you then you can follow up here. Good luck!

Grant


"Aaron Cohen" <amcohen@us.ibm.com> wrote in message
news:ig0kfa$jna$1@news.eclipse.org...
> Hello, I am writing a very small application and do not want to include
> the entire SWT jar due to size concerns. I was thinking of removing
> classes that I don't want from the jar but I am concerned about breaking
> dependencies. If I want to only use a few classes from the jar, what
> process should I follow to determine what files to keep and what to
> remove? Should I build SWT from source?
>
> Thank you!
>
> --
> Aaron
Previous Topic:Buttons in TreeEditor twinkle on item expand/collapse
Next Topic:Layout problem on windows 7.
Goto Forum:
  


Current Time: Fri Apr 26 14:01:30 GMT 2024

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

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

Back to the top