Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse not compile my servlet [closed]

I have eclipse project with many packages. I move one .java file from one package to another and then I try to compile. Compile was successful but this file hasn't been compiled. I restart eclipse but this problem still appear. I create new test class ant this class weren't compile again. I use Eclipse Indigo on Mac OSX 10.6.8 Can someone help me. Thanks in advance.

like image 554
nyanev Avatar asked Sep 29 '11 06:09

nyanev


People also ask

Why my servlet is not working in Eclipse?

Add the server runtime libraries In the window that appears, choose Java Build path on the left. Then choose the Libraries tab in the view that appears. Click the Add Runtime option and then select Server Runtime. Add the server runtime to the web project to fix the HttpServlet not found Eclipse error.

How do you resolve HttpServlet Cannot be resolved to a type?

The reason is the Java Servlet API is missing in the project's classpath. You can solve this problem by specifying a server runtime for the project, e.g. Apache Tomcat runtime – because a Java web server is a servlet container that implements the Servlet API.


2 Answers

Moving:

If you have moved the file within eclipse, you have been asked if all references should be updated. This you have to answer with "yes", as long as there are no (red) errors shown.

If you moved the file in the finder, move it back and do it again within eclipse. Make sure the new destination is in your src-folder.

Rebuilding project:

Go to the "Project"-menu and disable the menu "Build automatically". Then choose "Build all" from the same menu (make sure you selected your project in the "Package Explorer". Afterwards enable "Build automatically" again.

Check for errors:

Go into the "Problems"-panel and check if there is a message about any problems within your project. If so, try to fix them or post them here.

If it is still not working and no errors are shown, go further:

Check your project SetUp:

Right-click your Project and select the "Properties" menu from the appearung context-menu. Go to the menu "Java Build Path" in the appearing window and select the tab "Source" on the right site. Check if all your source folder are visible there. If not, add them there.

Repeat the steps above then.

like image 183
Erik Avatar answered Sep 19 '22 20:09

Erik


I suppose your setting for the java build path is not correct.

To check this right click on your project and select properties from the context menu. In the dialog click 'Java Build Path' / Tab Source and make sure that all folders containing your sources files are listed here, otherwise they will be ignored.

like image 27
stacker Avatar answered Sep 20 '22 20:09

stacker