2

Background

I've made a small util that can run on Windows OS (and probably others), using SWT , WindowsBuilder, and Eclipse as IDE.

The app is supposed to help developers to minimize their Android app's size, by converting images into WebP/Jpeg when possible. It's available here.

The problem

I wanted to make it easier for people to run it, so I've called "export as runnable jar".

Once I did this, I've noticed that from an app that takes just a few MB (needs SWT and an exe converter file), it got to be more than 20MB of storage.

What I tried

Looking at the files structure, I've found this:

enter image description here

The export wizard only has 2 steps: choosing to export as a runnable jar, and this one:

enter image description here

So I can't find out how to configure it. I tried to change the running-configuration, but it fails to run if I remove the additional jars:

Error: Could not find or load main class webpifier.Main

enter image description here

Choosing to restore the default entries, I get the additional jars:

enter image description here

The question

How could this be? Are all those jars needed? Is it possible to avoid having such a large chunk of added files? What is the purpose of those files?

For other OSs, will replacing just the SWT file (and the converter file) be enough so that the app will run? Or should I call the "export as runnable jar" on the other OSs too (this is Java, so why should I?) ?

android developer
  • 114,585
  • 152
  • 739
  • 1,270
  • Only you know, if all jar's are really needed. Maybe you referenced unused JAR's? When you are using Eclipse-RCP or SWT, all needed Eclipse/SWT-JAR's are also copied!) – Ben Mar 29 '16 at 07:36

1 Answers1

2

I'll post my comment as answer:

How could this be? Are all those jars needed?

Only you know, if all jar's are really needed.
All JAR's which are referenced to the project are normally also copied to the distribution-folder (also unused JAR's).
Further: When you're using Eclipse-RCP or SWT, all needed Eclipse/SWT-JAR's are also copied to the distribution-folder!

I suggest using Swing instead of SWT.
Swing is already included in Java-Libs, but SWT not.
So you don't need to distribute all those SWT-JAR's.

TIP:
To reduce the distribution size of your application, try to get rid of all: org.eclipse.*-Imports

For some more important info's regarding SWT vs Swing, see here:
Java Desktop application: SWT vs. Swing

Community
  • 1
  • 1
Ben
  • 3,378
  • 30
  • 46
  • Well I don't know. That's why I asked this. I used those tools and this feature, and this is what I got. About Swing, as I've compared it (a long time ago) with SWT, I find SWT more superior and also have better native look&feel. Also, since the project is already done, I think it will take too much time to convert to Swing. I don't even think that using Swing will help, except for the removal of the "swt.jar" file. Can you please try exporting the project as runnable jar and see what can be done (yet without ruining it of course) ? – android developer Mar 29 '16 at 08:26
  • The "swt.jar" file is only ~2MB. The rest is what I don't understand. – android developer Mar 29 '16 at 08:28
  • SWT.jar maybe has references to other org.eclipse.*.jar. or you are using classes from other eclipse.jar's. Look at all your `import org.eclipse.*`imports. Further: Today, swing's native Look and Feel does not really differ on Windows from other applications. – Ben Mar 29 '16 at 08:34
  • What is `com.ibm.icu*` used for? it is 11MB! – Ben Mar 29 '16 at 08:36
  • @androiddeveloper: You say converting to swing will **take too much time**, but you only have **8 classes (less then 2000 LOC)** in your whole project. I think it's worth the trouble! – Ben Mar 29 '16 at 08:43
  • I don't have any java file that has "import com.ibm.icu" or even "com.ibm.icu". All files were created automatically when doing the export. This is the tool for the UI designing: https://eclipse.org/windowbuilder/ . I've tried to delete the file, and the app still works, which is weird... – android developer Mar 29 '16 at 16:03
  • see here: https://wiki.eclipse.org/ICU4J but I don't have much experiences with Eclipse(-RCP). Maybe this lib is (referenced by Eclipse-RCP and) only needed in special cases (which don't apply to your project). Check your project/export settings. – Ben Mar 29 '16 at 16:13
  • There are no export settings. I've updated the question to show what I see and what I tried for this. – android developer Mar 29 '16 at 16:31
  • As you can see in your updated screenshot, `com.ibm.icu`is added as **User-Library/Entry**. I don't know who any why this lib was added and if you really need it.Maybe you choosed a wrong **Project-Template** or something... – Ben Mar 29 '16 at 16:35
  • I chose the only project that's related to SWT : "SWT/JFace Java Project" . – android developer Mar 29 '16 at 17:20
  • @androiddeveloper : try to remove lib by lib from your project until it doesn't work anymore. I sadly don't know which Libs your project needs. – Ben Mar 29 '16 at 18:28
  • I tried to delete as many as I could (and yet let it work), but still, some files there cannot be deleted, since the app won't work without them. I hope this won't break anything. Now it takes ~4.5MB. The question remains: what's with all those files, what are their purpose? Is it possible to minimize them when exporting? – android developer Mar 31 '16 at 06:40