3 messages in net.java.dev.jna.usersRe: [jna-users] Small Deployment for ...
FromSent OnAttachments
Dale...@coats.comApr 16, 2008 7:16 am 
Timothy WallApr 16, 2008 7:38 am 
Daniel KaufmannApr 16, 2008 4:28 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [jna-users] Small Deployment for Windows-onlyActions...
From:Daniel Kaufmann (dani@gmail.com)
Date:Apr 16, 2008 4:28:38 pm
List:net.java.dev.jna.users

There are obfuscator's that do find the unused classes, change private method names to shorter ones, and similar techniques to reduce the jar file. They are commonly used in J2ME. Here is a site on this http://mobilepit.com/10/j2me-how-to-optimise-your-jar-file-size.html and it mentions Proguard (http://proguard.sourceforge.net/) and RetroGuard as common obfuscator used. However I think you will have to remove the natives for other plataforms manually since I don't think obfuscator is going to do it for you. Cheers, Daniel

----- Original Message ----- From: "Timothy Wall" <twal@dev.java.net> To: <use@jna.dev.java.net> Sent: Wednesday, April 16, 2008 11:38 AM Subject: Re: [jna-users] Small Deployment for Windows-only

On Apr 16, 2008, at 10:16 AM, Dale@coats.com wrote:

First of all, fantastic job! I went to MSDN, picked up a few details on a Kernel32 interface, and had some native stuff running in minutes...great tool! I wish it was around years ago when I burned countless hours on JNI.

My question is about a Windows-only deployment and how I can get the size down (it was troubling to triple the size of my program to get the one call*).

The first thing I tried, which was quick and easy, was to unpack jna.jar, delete directories "darwin", "freebsd*", "linux*", and "sunos*", and pack it back up again. My test seemed to continue to work with this modified jar.

I just wondered if this was the "right" way to proceed, if I'm looking for trouble doing this, and if I can get even smaller using this technique. Realistically, I'm not going to have time to do a custom build, but to deploy a smaller package on Windows, I think I'm on the right track?

Your approach is perfectly reasonable, a given platform never references the natives for other platforms.

There are probably some other classes you could strip out (CallbackReference*, Callback*Context), but I don't know how much size you'd save doing that versus the work to find unused classes. You could always turn on debug class loading and strip out any classes not loaded when running what you *do* use.

You could also strip out the DLL version information from jnidispatch.dll; resources seem to take up more space than the actual information they contain (although I find it useful tagging information easy to examine in Windows Explorer).

--Dale--

* The one call is to keep Windows from sleeping on me: SetThreaExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED)