Results 1 to 6 of 6
  1. #1
    Drew345 is offline Member
    Join Date
    May 2015
    Posts
    31
    Rep Power
    0

    Default Making New Project caused Existing Project to stop working

    I am pretty new to Java and I am using the Eclipse IDE.

    I started my first project (named Test) and made a package (named test) and started on my first few programs (classes). The first programs were the simple “Hello World” or print “7 is an integer” type really easy programs. So far all is great.

    Then I made a new project (named JavaClub) to start putting in the work for a club I joined. Immediately on making the new project (JavaClub) half of the programs (classes) in the original project (Test) stopped working. I never changed anything in the programs (classes) in the Test project, they just stopped working when I made the new Project. Now when I open even the most basic program in the original Test Project, I get the error:

    Error: Could not find or load main class test.March20

    Where March 20 is the class and Java file name.

    Any idea why making a new project in Eclipse would cause the programs in another pre-existing project to stop compiling with that error?

    I’ll include a listing of the “March20” file here, but I don’t think the answer is anywhere in the code. This and other classes all compiled fine until I created the new project.

    Thanks for any tips!

    Listing of file “March20.java”

    package test;
    public class March20 {
    public static void main(String[] args) {
    int myarray[] = {2, 4, 6, 8, 10}, i;
    for (i=0; i<5; i++)
    {
    System.out.println(myarray[i]+" ");
    }
    }
    }


    Error: Could not find or load main class test.March20

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    14

    Default Re: Making New Project caused Existing Project to stop working

    Are you certain March20 is in the package "test"? Have you built the class files? Go to navigator and check the bin directories to see if the *.class files are there. You may also want to click on the Project menu item and ensure that build automatically is selected. And clean the project to cause a rebuild.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    Drew345 is offline Member
    Join Date
    May 2015
    Posts
    31
    Rep Power
    0

    Default Re: Making New Project caused Existing Project to stop working

    Thank you Jim, those were great ideas.
    I double checked and March20 is in the package "test"
    I checked in the navigator in the bin directory and the *.class files were NOT there. Odd, since they must have been there before since the program ran before.
    I checked the Project menu and Build Automatically is selected.
    I did the clean project, but still get the same error: Error: Could not find or load main class test.March20

    I learned a lot just from you advice, thanks so much. Any other idea I might try?
    Thanks,
    Drew

  4. #4
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    14

    Default Re: Making New Project caused Existing Project to stop working

    I can't say for certain. It has been my experience with Eclipse that it sometimes get's confused. Try making a small change to the program and saving. Sometimes a new save will cause the class files to be generated. A harsher approach would be to delete your the java file and then recreate it. I have had this problem myself and was unable to find any apparent reason. I finally took the "harsh" solution and all was well. Others may have a more tame solution.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  5. #5
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Making New Project caused Existing Project to stop working

    Quote Originally Posted by jim829 View Post
    I can't say for certain. It has been my experience with Eclipse that it sometimes get's confused.
    Yes but not at this low level. If it would screw up doing basic (re-)compile tasks Eclipse would be utterly useless and avoided by everyone.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  6. #6
    Drew345 is offline Member
    Join Date
    May 2015
    Posts
    31
    Rep Power
    0

    Default Re: Making New Project caused Existing Project to stop working

    Thanks for the suggestions.
    I tried copying the entire contents of my March20 class, then deleting the class (in the project browser in the left window) then making a new class with the same name (March20) then pasting in the contents I had copied at the beginning.
    Same error.
    So I made a new class called March21, pasted in the contents I had copied earlier, renamed the class as March21.
    And it ran just fine.

    Somehow I have confused Eclipse (in my first week!) and it refusing to recognize anything with the classname March20.

    Oh well, luckily this is just a practice program.

    Thanks for the help though, learning so much!

Similar Threads

  1. Creating a project in eclipse from existing project
    By Suraiya in forum New To Java
    Replies: 1
    Last Post: 10-08-2011, 09:14 AM
  2. making a working project from source and .jar libs
    By stringargs in forum NetBeans
    Replies: 0
    Last Post: 05-08-2011, 12:51 PM
  3. Adding a project to an existing project
    By Seijuro in forum NetBeans
    Replies: 4
    Last Post: 08-08-2010, 10:15 AM
  4. open existing project project ..
    By itaipee in forum Eclipse
    Replies: 1
    Last Post: 12-28-2008, 08:12 PM

Posting Permissions

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