FX Experience Has Gone Read-Only

I've been maintaining FX Experience for a really long time now, and I love hearing from people who enjoy my weekly links roundup. One thing I've noticed recently is that maintaining two sites (FX Experience and JonathanGiles.net) takes more time than ideal, and splits the audience up. Therefore, FX Experience will become read-only for new blog posts, but weekly posts will continue to be published on JonathanGiles.net. If you follow @FXExperience on Twitter, I suggest you also follow @JonathanGiles. This is not the end - just a consolidation of my online presence to make my life a little easier!

tl;dr: Follow me on Twitter and check for the latest news on JonathanGiles.net.


There have been a bunch of questions about how I packaged the FxExperience Tools app. Well this may not be the best way as I have not done this before for Mac and not for Windows for 6 years. So I was learning as I went but here is what I did:

Common Considerations

  • Do you include JavaFX?
    I would recommend that you do as you do not want your end users to have to think about finding and installing the appropriate version of JavaFX. Also if you want to have an exact version that you have done all your testing on then this is the only way to guarantee it.
  • Do you include Java JRE?
    This is exactly the same as including the JavaFX runtime and has all the same reasons for wanting to do it. For Windows it is a no brainer, just include it. For Mac its a little more complicated at the moment. For 1.6 it should be auto installed for you when needed and you can not redistribute it your self. And when 1.7 is generally available I would recommend packing it in your application.

Application Icon

You need to design a icon for application and make it in a number of different sizes and formats. I designed ours using Photoshop and created PNG files for each of the common sizes 512×512, 256×256, 128×128, 64×64, 32×32 and 16×16. As the icons gets smaller you will need to tweak/simplify the design so that you can still make out what it is showing when only having a few pixels. Once you have all the PNG files with transparency the next stage is to create a .icns file for Mac and a .ico file for Windows. These are special icon file formats that take all the sizes and combine them into a single file. Apple is very nice in providing a great tool for this in their free XCode tools suite. It is called Icon Composer and will take all your images and create both the Mac and Windows icon files for you.

Mac DMG

On Mac most applications are shipped as a DMG which is a vertical disk image. Inside of it it contains the Application and a link to the Applications folder so all you have to do to install is Drag and drop. So this is what I created for our FxExperience Tools application so it feels native for Mac users. There are two steps to this process:

Make Mac Application Bundle


For Java 1.6 Apple provides a tool for you called Jar Bundler that takes all your jar files and the jar and jnilib files from JavaFX and packages them into a single Application Bundle. On Mac applications are just special kinds of folders that act like a single file. You can right click and go “Show Package Contents” to see what is inside any application. Other than adding your files, all you need to do is drag and drop in your icon file and specify the main class. Then click “Create Application…” choose a name and you are done.

Make DMG Image containing your Application Bundle

Now that you have your Application Bundle you need to create a zip of DMG so that it can be stored and transmitted by non-macs and over the internet as a single archive. Also it lets you compress it so that it is smaller to download. Although a zip is good enough, a DMG gives you the chance to give your users a nicer experience which is what it is all about on the Mac. So to create a DMG I used the standard Mac tool that comes with every Mac called Disk Utility. So launch Disk Utility and click the “New Image” button, give it a name and keep the standard options. It will create your disk image and open it in finder as a new disk for you. You can then copy your application bundle into it and also create a alias(mac form of linked file) to the applications folder so that your user has a convenient place to drag your application to. Then for a nicer experience it is recommended that you give the disk window a background picture and make it icon view with the tool bar and side bar turned off.


One thing I did learn by mistake is you should put your background image inside your application bundle on the disk image then choose it from there in the view settings dialog. Otherwise it will create a link to it in its absolute location on your machine and will not show on other peoples computers. Last thing then is to size the window to fit your background image and position the window in the center of the screen. Then don’t close the window, just eject the disk using another finder window. Next you can open your DMG back up in Disk Utility and choose “Convert” then save a copy as a compressed format. Then you have your final image ready to ship. When a user opens your DMG they should see something like this:

Windows

For windows you need to use a installer maker tool. There are many commercial and free options for this. The one I used is Install4J from ej-technologies. It is commercial but simple to use and polished. It has the nice ability to be able to generate installers for all platforms from all platforms. So on Windows you can create a Mac installer and on Mac you can create a Windows installer. That is handy if you don’t have both platforms handy. At $2000 though its a big investment, but if you’re are shipping a quality application I think it is well worth the investment for the level of polish it offers and the lack of time and hassle of doing your own thing. They do offer free licenses for non-commercial OpenSource projects. I used a old version 3 (the latest is 5) that I had a license for from back when I was running my own startup. I will have to see if I can convince them to gave us a OpenSource license for fxexperience tools project :-). One of the things that it does so well is pack200 and LZMA compressing all the jars that go into the installer. It also makes it very easy to package the JRE inside you application. So for example the windows installer installer is 23Mb download including JavaFX and JRE 1.6 but uncompressed its 100Mb which is very impressive compression. Here is a list of other free windows installer creators that you may want to consider.

Bundling JavaFX

This should be simple with any of these installer tools, all you have to do is include the files from the “rt” directory of JavaFX then make sure the javafxrt.jar is in your application class path. Then it should work like magic 🙂

Conclusion

At the moment this is a little complicated process though using a commercial tool really helps. We would love to be able to provide a tool with JavaFX that makes this super simple but I am not sure when we will be able to commit to it. So this is a great place that the open source community could help with. There are loads of open source projects that do parts of it but nothing that does it all in one simple ant task which is what most developers want. So anyone looking to start a open source project and really help out their fellow developers this would be a great project. I would have a go myself if I had the time. Here are some links to other open source projects that solve parts of the problem. I did not find a free tool that lets you create windows MSI installers on Mac or Linux but feel like someone must have made one.