Solved

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

Posted on 2001-09-05
9
670 Views
Last Modified: 2007-12-19
I get this error when I compile my program.  Please tell me how to resolve it.
0
Comment
Question by:tinav
  • 4
  • 4
9 Comments
 
LVL 27

Expert Comment

by:rrz
Comment Utility
Please give more information.
Show us your code, and show us what you are typing at command line.
0
 
LVL 19

Expert Comment

by:Jim Cakalic
Comment Utility
When you compile (javac) or when you run (java)?
0
 

Author Comment

by:tinav
Comment Utility
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);
     myframe.setVisible(true);
  }  
  public static void main(String[] args) {    
     new Swing_Sample1();
  }  
}
0
 
LVL 27

Expert Comment

by:rrz
Comment Utility
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
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

 

Author Comment

by:tinav
Comment Utility
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
0
 
LVL 27

Expert Comment

by:rrz
Comment Utility
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.
0
 

Author Comment

by:tinav
Comment Utility
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?

Thanks
0
 
LVL 27

Accepted Solution

by:
rrz earned 200 total points
Comment Utility
I don't know which system you are working on , but for Win98
PATH=C:\WINDOWS;C:\WINDOWS\COMMAND;C:\jdk1.3.1\BIN
SET CLASSPATH=.
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
0
 

Author Comment

by:tinav
Comment Utility
Thanks.  I typed in the exact same thing for those three variables and it worked.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
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…

763 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

6 Experts available now in Live!

Get 1:1 Help Now