One of my friend was trying to come up with the Windows GUI program which could run directly from the CD or USB drive in most of the computers. In Indian institutions like schools , the computers are mostly out dated and only has IE 6 browser. HTML5 was not a good idea because it needs the latest browser and it can expose most of the code and resources on a commercial product. .NET licence was costly considering the small budget project and it was very difficult to find programmers with Delphi and Python (tinka) skills.
Java being so popular language, its very easy to code the GUI quickly, especially in JavaFx. JavaFx have mp3 audio file playing support. Now the big problem was any JavaFx program (jar) needs JavaFx runtime to be installed. This installation could not be expected to be done by school students or people who were new to computers without help of a system administrator. People might not have the correct version of runtime installed and may run into various compatibility issues.
Native packaging allows JavaFx programs to be shipped as exe wrapper file and its own runtime JRE directory.
Since JDK 7 Update 6 , JDK and JavaFx has been merged and there is no separate runtime directories.
One can get get the latest JDK 7u6 beta build(build 14 or later is recommended) On Windows/Mac/Linux it comes with JavaFX 2.2 SDK as part of JDK installation. the "Getting started with native bundles" section of Java Deployment blog can be referred for the detailed step.
For Netbeans JavaFx project , NetBeans 7.2 is required to support the latest JavaFx 2.2.
- Create a new JavaFx project and do you coding.
- Locate the project folder (mouse over the project node in the navigation pane ) and open the build.xml
- Add nativeBundles="all" attribute in the deploy tag
- Right click on the project tag and select "clean and build"
- Go back to the project folder and you can find the "bundles" folder in the usual "dist" folder.
- Inside the "bundles" folder there will be another folder with the project name and the executable will be inside it.
- Now you can double click and run the program.
- The "app" directory would contain the jar distribution archive.
- The folder called "runtime" contains the whole JRE (that includes the JavaFx runtime in the latest version)
- The whole bundle is portable to most of the computers, I have tested it in a computer where no Java is installed.
It is always recommended to have Java installed in all the computers for better performance and running other application but native packaging is very useful for light weight programs and a greater outreach.