Share your knowledge at the LQ Wiki.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 03-23-2008, 02:40 AM   #1
Registered: Oct 2006
Distribution: FreeBSD
Posts: 162

Rep: Reputation: 30
Exception in thread "main" java.lang.NoClassDefFoundError:

Here is my code.
class Ex13{
    public static void main(String args[]) throws IOException{
        BufferedReader keyboard = new BufferedReader (new InputStreamReader(;
        String input;
        int num = 0;
        int sum = 0;
        do {
        System.out.print("Enter a positive number: ");
        input = keyboard.readLine();
        num = Integer.parseInt(input);
        if ( num > 0)
            sum += num;
        }while (num > 0);
Compiling with javac was fine but somehow i got this error while run as java hh
Exception in thread "main" java.lang.NoClassDefFoundError: hh
   at gnu.j
Caused by: java.lang.ClassNotFoundException: hh not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:./], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
   at gnu.gcj.runtime.SystemClassLoader.findClass(
   at java.lang.ClassLoader.loadClass(
   at java.lang.ClassLoader.loadClass(
Hmmmm.. what went wrong? How do i fix it??

Last edited by LinuxNewbie999; 03-23-2008 at 02:41 AM.
Old 03-23-2008, 05:42 AM   #2
Senior Member
Registered: Oct 2006
Distribution: Slackware 12 Kernel 2.6.24 - probably upgraded by now
Posts: 1,054

Rep: Reputation: 46
The class containing main function needs to be public
Old 03-24-2008, 01:12 AM   #3
Registered: Oct 2006
Distribution: FreeBSD
Posts: 162

Original Poster
Rep: Reputation: 30
hmmm, thank you. After i change the java file name same as the public class, it works.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Exception in thread "main" java.lang.ClassFormatError: onmyown.Main (unrecognized cla zimboney Fedora 4 07-20-2007 02:00 PM
Exception in thread "main" java.lang.UnsupportedClassVersionError manolakis Programming 2 01-20-2007 11:56 AM
Java error "Exception in thread "main" java.lang.StackOverflowError" nro Programming 1 09-04-2004 04:47 AM
Exception in thread "main" java.lang.NoClassDefFoundError: Lobais Linux - Software 19 06-23-2004 09:42 AM
Exception in thread "main" java.lang.NoClassDefFoundError: melinda_sayang Programming 2 04-27-2004 12:49 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:13 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration