2

I am new to web development and I've downloaded some demo projects to learn how to develop REST client side application using Eclipse.

These are two examples:

first dynamic web project

second dynamic web project

I am trying to write some test cases using JUnit for project 1, however, Right Click (a class) => new Junit Test Case => the error happens all the time telling me "source folder is not on the java build class path" and I can not create the JUnit file.

But for the project 2, all the info is filled automatically.

If I right click src for second project and in build path "remove from build path", it will become the same format (folders) as proj 1. But hundreds of errors of source code about package name, and all the "import" statements.

Is it related to how Eclipse works? Could anyone give a simple explanation of how I can change the proj 1 to the correct format? I tried to "build path" for proj 1 and... hundreds of error of the source code..

Thank you!

Zzz...
  • 291
  • 6
  • 19

1 Answers1

3

In the project properties (right click on the project folder and select "Properties" from the menu) go to "Java Build Path" and add src as source folder.

Henry
  • 42,982
  • 7
  • 68
  • 84
  • yes, I tried this. but there will be hundreds of errors of the code and also the package path does not match, should I correct them manually? and another problem is: all the import. statements become incorrect – Zzz... Jan 06 '15 at 08:49
  • If there are errors in the project you need to correct them. Just not compiling the offending classes gets rid of the errors but is not a solution. – Henry Jan 06 '15 at 08:54
  • thanks. I have another confusion: for the second proj, I followed the instructions and can run it to GET or POST data, but after "build the path" all "import"s become invalid and do I need to download all the necessary jars? (but why proj1 can run without any manually downloading the jars, instead?) – Zzz... Jan 06 '15 at 09:05