Smallest standalone SWT Hello World?
I am writing some small utilities written in Java which I intend to distribute online, and my biggest concern is file size. Bundling it with the most recent JVM in the "dumb and easy" way will yield a huge download although my tool is less than 100kb.
Another problem is my potential users are not IT professionals, and would not know how to install a JVM. So, it all should be bundled together as one easily installable package.
Yeah, I know, this could easily be done using C or another language I guess, but for productivity reasons and also preference I really want to use Java. :)
It's a bit challenging, but so far my idea is to use the classpath project together with an alternative JVM than Sun's. Then, when building the program, use an obfuscator to remove any classes that is not needed. Finally packing it all together with the JVM using some standard Windows installation tool like Inno Setup.
So, my question is, anyone here has recommendations for a good, fast, tiny JVM that will work with SWT? And in general, do you have any experience with this, and how small did you manage to make the final redistributable?
By the way, only needs to work on Windows...
Thank you, any ideas are welcome... :)
[1257 byte] By [
javasvadaa] at [2007-11-26 23:48:39]

This may not be called as an standalone but how about using a web browser to run the program.Web browser like IE comes with Microsoft JVM ?
rym82a at 2007-7-11 15:24:28 >

Ignore the web browser comment, the Microsoft JVM is outdated and unusable.
The problem with bundling the JVM is that they still have to install it and it gets outdated. Can't you just add instructions on how to install the JRE and provide some shell scripts/runnable jar to run the program?
The reason I mentioned about the web browser because I assume the target users only have basic knowledge of using computer.
They may not even know how to install JRE or what it is.
Microsoft JVM may be outdated or not as powerful as Sun JVM, but if the application is fairly simple it does great job.
Of course I agree to provide the instruction of manual JRE installation if the target user know how.
rym82a at 2007-7-11 15:24:28 >

just for curiosity.. cant you change your java file to JNLP, then you can put tags in your website to automatically install JRE in their system..if I am not mistaken
> Microsoft JVM may be outdated or not as powerful as> Sun JVM, but if the application is fairly simple it> does great job.The Microsoft VM is not installed in new computers.Kaj
kajbja at 2007-7-11 15:24:28 >

don't forget that the SWT libraries - both the jars and the native libraries - are fairly large as well. I don't think you'll find a solution to this. you don't need to be an IT professional to install a piece of software like a JRE, though. I don't think you're giving your users enough credit. just give them a link to Sun's JRE. it shouldn't pose them any more problems than installing your software
and it would be a headache persuading a browser-based JRE to find the SWT libraries, and I don't think it would render SWT anyway
Thanks for all comments, appreciate it.
Note that although I could potentially trigger a download of the JVM and install it automatically, to take the burden off the users, it still leaves the problem with taking a lot of time to download, and potential problems with connection or URLs to the JVM changing. Also, the user might be suspicious why the program wants to be unblocked from the firewall even though it has no reason to go online based on the description of the program. I can see many other problems too, but to cut it short, I do not want to have the user install the full heavyweight JRE. Avoiding this is basically what this thread is about... :)
To put it short: I want the program to install and behave like every other Windows application. I believe this is possible through the method I described earlier.
About the size of SWT: This is not a problem, the DLLs and class files are in fact very small after compression by 7zip and obfucsation/removal of unused classes (less than 100kb!). The main concern is the rt.jar file, which is huge and contains 99% classes I will never need.
As you probably know, Sun's JVM license forbids tempering with the original files in any way, meaning I cannot remove the unused classes from rt.jar. Thus, to do this in a legal way, I need to use the Classpath open source classes instead, together with a JVM that's compatible with both the classpath as well as SWT.
So, I am looking for a good, fast and small JVM which fits the above criteria. I have found many JVMs out there, but it is very hard to judge whether they are any good or not., so any tips would be appreciated. Also, I would also like to hear about any alternative ideas for solutions fitting the description above. :)
I found this page, which has quite a lot of info about alternative JVMs, however it lacks any recommendations:
http://www.gnu.org/software/classpath/stories.html#jvm
In Previous OS there was an exe jview or some like that in systsm32 folder.You can run the java programs through it with out installing the extra JVM. But at that time it has no support for swing.But I don't know still there is any support for JAVA from Microsoft
> In Previous OS there was an exe jview or some like
> that in systsm32 folder.
> You can run the java programs through it with out
> installing the extra JVM. But at that time it has no
> support for swing.
>
> But I don't know still there is any support for JAVA
> from Microsoft
>
Unfortunately after Sun's lawsuit against Microsoft they ensured Microsoft could no longer provide their "polluted" JVM in Windows, so it is no longer included. Also, they have not updated it for nearly a decade.
A tiny % of PCs comes with Java preinstalled, but in general not. This makes it very hard to distribute Java client applications without forcing the user to install the mega-JVM from Sun. It's one of the reasons Java mainly is used server side. But it's a pity, as in my opinion Java is a far superior language over for example C++, which is normally used to make Windows programs, and scores way higher as a RAD.
Yes, I agree. But for a standard PC, the browse should able to run applet (JVM pre-installed)? If it is no, you must find a tiny JVM together with your program.
rym82a at 2007-7-11 15:24:28 >

The applet can do alot except the special tasks (reading or writting to the local machine and other stuff which can harm the underling system) which any other application can do.
For this you have to sign the applet.
I think this is a nice idea to have signed applet with the functionality you want.
> The applet can do alot except the special tasks
> (reading or writting to the local machine and other
> stuff which can harm the underling system) which any
> other application can do.
>
> For this you have to sign the applet.
>
> I think this is a nice idea to have signed applet
> with the functionality you want.
>
Please see above, Windows does not come with a pre-installed JVM. So, it cannot run Applets nor Applications out of the box.
I think I can run applets in win200, xpI have no spare machine so I can check this out. But Internet Explorer still supports the applets.
> I think I can run applets in win200, xp
>
> I have no spare machine so I can check this out. But
> Internet Explorer still supports the applets.
>
Yes, you might have, however, this is not the norm:
http://www.mvps.org/marksxp/WindowsXP/java.php
I'm sorry for this but, what are you using to remove the unused classes? I tried to do something like that before but couldn't really find a way...
> I'm sorry for this but, what are you using to remove> the unused classes? I tried to do something like that> before but couldn't really find a way...and also, how do you know which ones are unused? "anything my class doesn't import" isn't the