Solved

My Java apps run slow

Posted on 2004-09-30
6
353 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Way to decrease size of apk file 9 112
jmss example java 2 34
What browser will run Java? 7 129
American Express @Work site and Java 4 69
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
In this post we will learn different types of Android Layout and some basics of an Android App.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

730 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