Solved

My Java apps run slow

Posted on 2004-09-30
6
351 Views
Last Modified: 2010-08-05
Hi Experts

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.

E.g.

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?
0
Comment
Question by:Mr_A_Smith
  • 4
  • 2
6 Comments
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 20 total points
ID: 12195001
>>
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.
>>

They usually do ;-)
0
 
LVL 21

Accepted Solution

by:
MogalManic earned 30 total points
ID: 12196877
The designers of the SWING API sacrificed efficiency for portablity.  Instead of using the native API for building widgets and form elements, all of the functionality is written in Java.  This gives you the ability to write the code once and it will work EXACLTY the same in Windows, Mac, MOTIF...

VB on the otherhand only runs on Windows, so it uses DLL's and Windows API functions to build its GUI.  This means it will run almost as fast as any C appliation.

Eclipse (http://www.eclipse.org) is a Java application that does NOT use Swing.  It uses a native library for its GUI and distributes a different native implementation for each OS.  If an OS does not have a particular widget, it will be implemented in Java.  If it does have the widget, the API will call the native API to build and interact with the widget.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12197832
Is Eclipse a hungry animal nonetheless MogalManic? - ive never used it
0
ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

 
LVL 21

Expert Comment

by:MogalManic
ID: 12198369
What do you mean by "hungy"?  Does it use lots of memory? no

I develop on a machine that has 512M and have never run out of memory. (Except when my program has memory bugs)

Another Java IDE I use at work, IntellaJ, DOES use lots of memory though.  It all depends how the applicaiton is written and how things are stored in memory.  It seams that for IntellaJ, alot of things are cached and that uses memory quickly.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12198429
Thanks
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12203333
8-)
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Where to store the queries for modification of table 4 62
table example 4 29
pagenation logic how it is working in my code 1 30
eclipse console opening separately 2 21
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question