Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,414 members, 7,819,489 topics. Date: Monday, 06 May 2024 at 05:06 PM

Exception In Thread "main" NoclassDefFoundError; Class Name - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Exception In Thread "main" NoclassDefFoundError; Class Name (3752 Views)

If You Don't Catch An Exception, PHP Spills Your MySQL Account Info By Default / Exception While Reading JSON Object In Java / Is Main Function In C/c++ User Defined Function Or Predefined Function? (2) (3) (4)

(1) (Reply) (Go Down)

Exception In Thread "main" NoclassDefFoundError; Class Name by Taysay(m): 5:27pm On Oct 05, 2006
Good day All My People( Java People)
Please is any one aware of this  error message -Exception in thread "main" java.lang noClasssDefFoundError; Class name,  my compiler just started behaving fuuny i was compiler and ruuning from text pad all of a sudden this error message popped up even for classes that compiled and ran successfully, i went back to my coomand prompt only to get the same meesage , i even uninstalled my jdk, reinstalled but the same error applies. please what do i do to get out of this ditch, thanx have a good one.
Re: Exception In Thread "main" NoclassDefFoundError; Class Name by sbucareer(f): 2:37am On Oct 06, 2006

There are possible cause to this problematic situation:

1. You classpath is not set i.e SET %PATH%;%JAVA_HOME%\bin in your environment variables
2. You program or class do not have a main method i.e. public static void main(String args[])
3. Your IDE is not set either in the options/preferences tab to locate the environment variables or JDK HOME
4. Also set you working directory to the classpath i.e. %PATH%;%JAVA_HOME%\bin;C:\temp\java

Let me know if you still have issues
Re: Exception In Thread "main" NoclassDefFoundError; Class Name by Taysay(m): 2:14pm On Oct 06, 2006
Good Day,
thanx for your speedy reply, On the issue of "main method" thats not d problem, I do not use any IDE, the issue is this, things were running very fine till this problemb came up, so I was amazed, to see this error even on all other codes that ran just fine , well I will go and try your suggestion then holla back at u .Or do u this I should just get and IDE to work with? if yes which one do you recommend,
thanx have a good one wishing you well in all your endeavours
Re: Exception In Thread "main" NoclassDefFoundError; Class Name by sbucareer(f): 2:31pm On Oct 06, 2006

I will recommend DrJava for it simplicity. But if you are advance programmer you should try Netbeans or eclipse
Re: Exception In Thread "main" NoclassDefFoundError; Class Name by mimohmi(m): 2:09am On Oct 09, 2006
@Taysay

Thanks for your mail, but sorry for my late reply. If you have followed all the advice given
still doesn't work, check your class name, make sure you save the file with the class name, and pass
that same name to the compiler and java. e.g
If i have this class;

public class Demo {
    public static void main(String [] args){
        new Demo();
   }
}

save the file as Demo.java. to compile

javac Demo.java

and to run

Java Demo

If you have multiple JVM, unistall the two, try re-installing each one and try you application.
if this doesn't work, let me know the version you are using ie both the JDK and JRE. To get
the versions type

javac -version   ------ for jdk
java -version     ------- jre

Before I forget, also make sure the class file is in your classpath. Or just go to the folder directly and
compile directly and also try running from the folder. e.g if i saved my Demo.java in say c:\project
cd to C:\project

c:\project javac Demo.java
"" "" java Demo
Hope it helps
Re: Exception In Thread "main" NoclassDefFoundError; Class Name by Taysay(m): 5:10pm On Oct 09, 2006
Good DAY,
How is the going, pls I was thinking of reformating my hard disk then reloading Xp then the JDK to see what happens , another option I was looking at, was using MacOS(tiger) since it comes with the tiger I feel this problem shouldnt come up, so what do you think pls I really want to know b'cos I havent being doing anything ever since this ugly problem came up.
Thank you looking forward to hear from u asap. have a wonderful week
taysay
Re: Exception In Thread "main" NoclassDefFoundError; Class Name by Taysay(m): 5:15pm On Oct 09, 2006
NB
I have done all that, and everything was working just fine before this problem came up.
Re: Exception In Thread "main" NoclassDefFoundError; Class Name by Taysay(m): 5:20pm On Oct 09, 2006
NB
I have done all that, and everything was working just fine before this problem came up. i am using 1.4.0 then changed to 1.4.1.
Re: Exception In Thread "main" NoclassDefFoundError; Class Name by mimohmi(m): 12:27am On Oct 11, 2006
@Taysay

Ok, just remembered, had a similar experience some time back. Which text editor are you using ?
The type of text editor can also cause such problem. When i used kedit(linux text editor for KDE )
the javac command runs fine but some how does not create the class file, which of generates the above error.
So, try using notepad to test a simple application, ie run the javac command and check if the
corresponding class file was created. if created run the java command. This should fix the problem.
Meanwhile thanks for the mail and call, hoping to see you, when you land lagos.
Re: Exception In Thread "main" NoclassDefFoundError; Class Name by Taysay(m): 11:17am On Oct 12, 2006
@Mimoh_Mi,
Good day, pls just incase you get to log in before my call gets through, I am in lagos at the momemt like I told u yesterday, but your number is palying hard to get, I am in a cafe (Go internet) new Line insurance building close to Mobil filling station Apapa. Tanx have a good one
Re: Exception In Thread "main" NoclassDefFoundError; Class Name by JFrame: 10:04am On Feb 05, 2010
Scan your system for virus, uninstall the jdk and reinstall it after the scaning and virus sweep, some virus infect the Javac.exe and java.exe files,
Re: Exception In Thread "main" NoclassDefFoundError; Class Name by chalise: 6:18pm On Feb 05, 2010
DO NOT REINSTALL anything, IT won't Help!

This happened to me b4. I lost a bit of hair and grew some gray ones before i figured out the reason why it happens.
The reason this happens is is because your compiler is referring to an older version of your files rather than the newer most recent ones. you said your program complied fine yesterday and today  it is not. this is because any changes you have made today are not being reflected on the actual file. Even if you save, close the program and open it again and compile you will still get  that same error because for some reason it is not over writing the older files when you modify the files and save.
To FIX this you need to Clean and rebuild . Just delete the classes that are causing the problem.THERE MUST BE NO TRACE OF IT.   create another class with the same name as the class you just deleted and paste the code into it. Now when you compile your compiler will be able to find the news most updated files.   

I am using Netbeans 6 and the solution to this is to use the clean and rebuild option and that does everything for you. 

Another Solution is to create another java application and move all your files there and work from that location.

(1) (Reply)

Please Note Only For Programmers.. / What Do You Think Of This Program I Wrote / Benefits Of Hacking, Reliable Schools Offering It?

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 27
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.