DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    SeanB Guest

    Exception in thread "main"


    I have just installed jdk1.4 and am getting an error when I try to compile
    a simple program. The source code is:

    /*
    this is a simple java program

    Call this file Example.java.
    */
    class Example {
    //a Java program begins with a call to main()
    public static void main(String args[]) {
    System.out.println("Java drives the web");
    }
    }

    The error Im getting is

    Exception in thread "main" java.lang.NoClassDefFoundError: c:\jbg\Example

    I get this error when I try to run the program. The program does compile.

    Thanks for the help in advance

    Sean
    sbradley05@snet.net

  2. #2
    Hiranya Samarasekera Guest

    Re: Exception in thread "main"


    if your compiled class file is in this directory [c:\jbg\Example\], include
    the folowing code to your autoexec.bat or just give this command on the prompt.

    set classpath=.;c:\jbg\Example

    try running it now.

    bye,
    Hiranya Samarasekera

    ----------------------------------------

    "SeanB" <sbradley05@snet.net> wrote:
    >
    >I have just installed jdk1.4 and am getting an error when I try to compile
    >a simple program. The source code is:
    >
    >/*
    >this is a simple java program
    >
    >Call this file Example.java.
    >*/
    >class Example {
    >//a Java program begins with a call to main()
    >public static void main(String args[]) {
    > System.out.println("Java drives the web");
    > }
    >}
    >
    >The error Im getting is
    >
    >Exception in thread "main" java.lang.NoClassDefFoundError: c:\jbg\Example
    >
    >I get this error when I try to run the program. The program does compile.
    >
    >Thanks for the help in advance
    >
    >Sean
    >sbradley05@snet.net



  3. #3
    Volker Held Guest

    Re: Exception in thread "main"

    this will also happen if you try to run the class file with itīs
    extension - in this case "java c:\jbg\Example.class" - to compile it you
    need the file extension, to run it you donīt...

    Volker

    Hiranya Samarasekera wrote:
    > if your compiled class file is in this directory [c:\jbg\Example\], include
    > the folowing code to your autoexec.bat or just give this command on the prompt.
    >
    > set classpath=.;c:\jbg\Example
    >
    > try running it now.
    >
    > bye,
    > Hiranya Samarasekera
    >
    > ----------------------------------------
    >
    > "SeanB" <sbradley05@snet.net> wrote:
    >
    >>I have just installed jdk1.4 and am getting an error when I try to compile
    >>a simple program. The source code is:
    >>
    >>/*
    >>this is a simple java program
    >>
    >>Call this file Example.java.
    >>*/
    >>class Example {
    >>//a Java program begins with a call to main()
    >>public static void main(String args[]) {
    >> System.out.println("Java drives the web");
    >> }
    >>}
    >>
    >>The error Im getting is
    >>
    >>Exception in thread "main" java.lang.NoClassDefFoundError: c:\jbg\Example
    >>
    >>I get this error when I try to run the program. The program does compile.
    >>
    >>Thanks for the help in advance
    >>
    >>Sean
    >>sbradley05@snet.net

    >
    >




  4. #4
    Join Date
    Apr 2007
    Posts
    11
    Attach software www.cajoon.com to your Java environment (J2SE, J2EE) and get 'root-cause' for every exception . . .

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links