Results 1 to 7 of 7
  1. #1
    Ms.Ranjan is offline Member
    Join Date
    Jun 2008
    Posts
    85
    Rep Power
    0

    Default Using Eclipse IDE:java.lang.NoClassDefFoundError: main

    Hi
    Java Code:
         package Try;
         import java.io.File;
                        public class Try 
                               {
    			public static void main(String args[])
    		               {
    			String tmp=System.getProperty("user.dir");
    			System.out.println(tmp);
    		              }
    
                                }
    The above code works fine when i compile and run it in command line window.
    When I run the same code in Eclipse IDE 3.4.1.

    "Could not find the main class.The program will exit" and in the console of the IDE I get this
    Java Code:
       
    java.lang.NoClassDefFoundError: main
    Exception in thread "main"
    So I went throu previous threads.Try to set the class path in two places.One in the properties window of the package and other was in the run configuration.

    I even tried the clean option as suggested in blogs,so that i could build the .class file,newly.

    But nothing is working i get the same error..
    Any suggestions ? or am i missing something..
    Need help immediately

  2. #2
    Ms.Ranjan is offline Member
    Join Date
    Jun 2008
    Posts
    85
    Rep Power
    0

    Default

    the problem which i am working on needs to have java 1.5 compliance.But eclipse compiler had java 1.6 compilance,so i had to change the jre from default 1.6 to 1.5,so does that have anything to do with my problem????

    i am not able to proceed...i am just stuck up with this..any help plz?????

  3. #3
    emceenugget is offline Senior Member
    Join Date
    Sep 2008
    Posts
    564
    Rep Power
    7

    Default

    in what directory are you running the program, and what does your directory structure look like? did you develop this code and directories using eclipse or just a text editor?

  4. #4
    Ms.Ranjan is offline Member
    Join Date
    Jun 2008
    Posts
    85
    Rep Power
    0

    Default

    eclipse workspace is the directory in which i am running the program..directory structure look like? its in C:\Documents and Settings\Administrator\workspace\Try\Try

    i just copy pasted the code from a tutorial,but made changes in eclipse...changes like the package name,the class name...

  5. #5
    uncommon is offline Member
    Join Date
    Dec 2008
    Posts
    30
    Rep Power
    0

    Default

    Try this.

    Inside of eclipse, create a new project. Name it whatever
    Right click that project and add a new class.

    Paste this inside the class and it should work:

    Java Code:
        public static void main(String args[]){
            String tmp=System.getProperty("user.dir");
            System.out.println(tmp);
        
        }
    Your code was right, but I think making changes to the package name and class name after the fact created some issues.

  6. #6
    Ms.Ranjan is offline Member
    Join Date
    Jun 2008
    Posts
    85
    Rep Power
    0

    Default

    Hi

    I just did exactly what you said..created new Java project,with new package and class name,pasted the above code..its just the same..main class not found,program will exit...

    I thought of learning and working with eclipse IDE,I am just wasting time on it..the program works just fine with command line window..i wonder how ppl use IDE???

    anyway,still i am open to suggestion or help...

  7. #7
    uncommon is offline Member
    Join Date
    Dec 2008
    Posts
    30
    Rep Power
    0

    Default

    An IDE is a wonderful thing. Once you get used to working with it you will wonder how you ever developed without it.

    It may not seem like it while your learning how to use it, and writing small applications, but when you are writing enterprise software, and dealing with 50 classes and thousands of lines of code... it's nice.

    Try right clicking on the errors (before trying to run them) and selecting 'Quick Fix' from the options.

Similar Threads

  1. Replies: 12
    Last Post: 06-06-2012, 09:04 AM
  2. Replies: 5
    Last Post: 09-03-2008, 05:29 PM
  3. Replies: 6
    Last Post: 08-18-2008, 06:44 AM
  4. Replies: 1
    Last Post: 08-06-2007, 06:07 AM
  5. Replies: 2
    Last Post: 08-01-2007, 05:26 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •