Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


error 'Exception in tread "main" java.lang.NOClassDefFoundError: programname

Posted on 2001-09-05
Medium Priority
Last Modified: 2007-12-19
I get this error when I compile my program.  Please tell me how to resolve it.
Question by:tinav
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
  • 4
LVL 28

Expert Comment

ID: 6457694
Please give more information.
Show us your code, and show us what you are typing at command line.
LVL 19

Expert Comment

by:Jim Cakalic
ID: 6457696
When you compile (javac) or when you run (java)?

Author Comment

ID: 6458134
Sorry about that.  When I compile (javac), it compiles without error.

When I run it lfrom ms_dos like: java Swing_Sample, I get the error.

The program is:
import javax.swing.UIManager;
import java.awt.*;

public class Swing_Sample1 {

  public Swing_Sample1() {
     DisplayFramejr myframe = new DisplayFramejr();
     Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
     Dimension frameSize = myframe.getSize();
     if (frameSize.height > screenSize.height) {
       frameSize.height = screenSize.height;
     if (frameSize.width > screenSize.width) {
       frameSize.width = screenSize.width;
     myframe.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
  public static void main(String[] args) {    
     new Swing_Sample1();
The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

LVL 28

Expert Comment

ID: 6458202
You said
>When I run it lfrom ms_dos like: java Swing_Sample, I get the error.
Don't you mean to enter Swing_Sample1

Author Comment

ID: 6458287
Yes, sorry again. I giess I am still new at this.  I say:
> java Swing_Sample1
and I get error
'Exception in tread "main" java.lang.NOClassDefFoundError:  Swing_Sample1
LVL 28

Expert Comment

ID: 6458798
Is Swing_Sample1.class  in your classpath?
Do you have it in your working directory?
Tell us more about how you are doing things,step by step.

Author Comment

ID: 6459037
I think you are on the right track.  Maybe the classpath variable is not setup right because, I just  found out that I get this message for every program that I compile and run.  All compile fine and don't run.  

I am using jdk1.3.1_01 that I just downloaded and I have my programs in a directory called java and I cd to that directory and say:

C:\java\java Swing_Sample1

The class files are already created in the directory.  Someone told me to go to the bin directory of JDK and run it there.  I moved my programs thare and it didn't make any difference.

Can you tell me what path and classpath variables needs to be for jdk1.3.1?

LVL 28

Accepted Solution

rrz earned 800 total points
ID: 6459154
I don't know which system you are working on , but for Win98
SET JAVA_HOME=C:\jdk1.3.1

If you put it in C:\jdk1.3.1_01 then use that instead of jdk1.3.1

Author Comment

ID: 6461017
Thanks.  I typed in the exact same thing for those three variables and it worked.

Featured Post

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
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

688 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