Posts

Showing posts from August, 2010

Using Code Optimization Software to reduce the size of JavaFX Applications

Image
You may increase the efficiency of your Java applications by applying some optimization methods on the Java byte-code. Shrinking and obfuscation are commonly used for this purpose. Shrinking is the process of removing unused classes, methods and fields, resulting in the processed byte-code having smaller size. Obfuscation is primarily used to make the code harder to debug and reverse-engineer. As an additional feature, obfuscation also reduces the size of the byte-code, since this process replaces the identifers in class files with shorter ones.

Reduction in the size of byte-code often implies an improvement in load time. Applet developers could especially benefit from such optimizations, since the transfer of compiled code accross a network is an important bottleneck.

In this article, I will show the use of optimization methods on a sample JavaFX application. I will use ProGuard 4.5 as the optimization tool. I choosed this tool, because it is available under the GPL free licence, ea…

Loading JavaFX Application Resources

As you might already know, JavaFX allows you to use your existing Swing components in your applets. All you have to do is to add a few lines of JavaFX code. However, you may run into unexpected problems because of Java Web Start security model. We had such an issue in one of our projects, when we tried to transform a custom swing component into a JavaFX widget. The problem was that the resources such as button icons were not being loaded correctly. When I investigated the code, I noticed that I was using ClassLoader.getSystemClassLoader calls to load resources. However, Java Web Start uses a user-level classloader to load the application resources instead of the system classloader. I got rid of the problem by replacing ClassLoader.getSystemClassLoader calls with this.getClass().getClassLoader().
You may find more information about this issue at http://download.oracle.com/javase/1.5.0/docs/guide/javaws/developersguide/faq.html#211.
I hope this tip saves some time for you.


Yücel Ünlü