Solved

My Java apps run slow

Posted on 2004-09-30
6
346 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now