Solved

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

Posted on 2001-09-05
9
684 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
[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
  • 4
9 Comments
 
LVL 27

Expert Comment

by:rrz
ID: 6457694
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
ID: 6457696
When you compile (javac) or when you run (java)?
0
 

Author Comment

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

Expert Comment

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

Author Comment

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

Expert Comment

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

Author Comment

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

Thanks
0
 
LVL 27

Accepted Solution

by:
rrz earned 200 total points
ID: 6459154
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
ID: 6461017
Thanks.  I typed in the exact same thing for those three variables and it worked.
0

Featured Post

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

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…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
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…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

623 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