My Java apps run slow
Posted on 2004-09-30
I've been using Java for under a year now and have noticed that most of my Java applications with GUI's (using Swing) run rather slow compared to programs i've written in other languages.
A while back I wrote a very simple application in Microsoft's Visual Basic, this application was a simple text editor (a bit like windows notepad but with less functionality), anyway, this app allowed the user to open a text file from the disk by using a common windows open dialog.
Now, recently I wrote a similar application in Java (using JFileChooser as the file open dialog). I noticed that my Java text editor ran very slowly. The Java application was deployed in a JAR executable.
Here are the things I noticed:
When opening the Java text editor by double clicking the jar it took a few seconds to open the application (ie. load the main GUI). I thought this could be because i had compressed the jar file and that when i open the file it may take a while decompressing, so i created another jar executable file with no compression. I noticed a very slight improvment on speed performance.
However comparing the speeds at which the Java app loaded to the VB app, the VB app loaded faster.
Now when i click file -> open (on my VB text editor), the open dialog appears much faster than when i try file -> open on my java app. The JFileChooser loads a bit slower (i used JMenu, JMenuBar, JMenuItem etc for the menu).
Ive noticed this speed problem with most of my java apps and cant find out what's the cause?
Any ideas? Does it have something to do with the JVM? Is this common?