[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

My Java apps run slow

Posted on 2004-09-30
6
Medium Priority
?
357 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 80 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 120 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

656 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