Pergunta

I created a simple project using WindowBuilder in Eclipse and my goal is to send it by email. I don't know what kind of computer the person is using, so I exported my project into a 'Runnable JAR File' and checked the option 'Extract required libraries into generated JAR'.

The problem is that the generated JAR file is 20MB in size!!! The project has only one simple window - nothing complicated or fancy.

I found that some people use ProGuard to include only what is really needed.

I would like to know if there is a way to optimize it 'manually'? Are there libraries that are automatically included when creating a WindowBuilder project, and how may I determine which libraries I can remove?

Thank you.

Foi útil?

Solução

I've had the same Problem using WindowBuilder. My solution was to look for the imports in my .java file, e.g.: import org.eclipse.swt.SWT; In the Project Explorer in Eclipse you can see that there are much more imports than needed. Those 'Build Paths' can be removed carefully. Simply rightclick on a .jar import like "com.ibm.icu_52.1.0.v201404241930.jar" and click on "Build Path" and "Remove from Build Path". Unfortunately, you can't remove or delete the packages inside the .jars. But using this method, I managed to reduce the size from 20.7MB to 3.87MB. It's something...

Outras dicas

Like fge said, send the source. Or upload the .jar to dropbox if you require you partner to access all of the files in the .jar.

If you don't like dropbox, find some other cloud storage solutions through a google search. Github or Bitbucket could also be an alternative to dropbox.

Cheers.

Use the Eclipse plugin FatJar. FatJar shows you which libraries are getting imported and allows you to specify which .jars, libraries, etc., that you want built into your JAR.

FatJar

Your jarfile is too big due of the project template. Create a sample java project, then use windowdbuilder components. Do not create a project Swing Template, by this way eclipse is gonna import all eclipse gui toolkits.

Tried it out with my way, my application's length equals to 3Ko against 24MO with the template project

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top