Search code examples
javaeclipsemavenbuildpath

Issues with maven project running in eclipse, not recognized as Java project


I've imported an existing maven project into Eclipse. I tried to set up the configurations for a JUnit test, and my project wouldn't come up as a testable project. When I typed in the project name manually, I was given the message:

Specified project is not a java project

I've also noticed that when typing code and trying to call a method e.g. "System.out" a message pops up when I type the period, saying:

This compilation unit is not on the build path of a java project

Additionally, there are no actions available when I right click the project and navigate to Build Path.

Having looked this up on here and elsewhere, I've followed the following pieces of advice, without success:

I've verified the existence of .project and .classpath files

I've looked in the .project file and verified the inclusion of a javanature

I've run mvn eclipse:eclipse

I've right-clicked the project in the PackageExplorer > Maven > Update Project Configuration

Java is not listed as a project facet but I'm not sure I should mess with that because I've tried clicking that, and that caused the entire project to be filled with errors (I think related to build path, but I can't quite remember). Removing Java as a facet didn't get rid of the errors and I had to re-import the project from scratch.

Sorry if any of this is vague, and thanks for the help.

I'm using m2eclipse.

EDIT: Problem was solved simply by deleting the project from my workspace, deleting all .project, .classpath files and .settings folders, and re-importing. I don't know why it didn't work the first time.


Solution

  • Problem was solved simply by deleting the project from my workspace, deleting all .project, .classpath files and .settings folders, and re-importing. I don't know why it didn't work the first time. Thanks for the help, everyone.