"Source folder is not a Java project" error in eclipse - java

I am trying to import maven project into eclipse 4.2 version.Its not importing the project properly. Its giving me error "Source folder is not a Java project" while I am trying to create a new call in it. Even ctrl+mouse click is also not working. I don't understand the problem. Even when I right click on project and select build path it shows me no action available. Anyone face the same issue

In the maven project directory try
mvn eclipse:eclipse
that may do the trick.

I ran into the same issue and fixed it by converting my project to faceted form.
Right click your project > Properties > Project Facets > Convert to Faceted Form, and select Java.

I had the same problem... But you just need to update "source Folder" to correct source "src/main/java" from whatever mentioned in the pop up:
[]

Either turn your project into Eclipse project, using mvn eclipse:eclipse, or install Maven Integration for Eclipse plugins, like m2eclipse, and import project as a Maven project.

I got the same error in a slightly different context (Indigo with m2eclipse):
I imported a multi-module (1 jar module and 1 war module) maven project into Eclipse. Everything worked fine (clean, install OK) until I tried to add a new class to one of the modules and got the "Source Folder is not a Java project" error.
I solved this by opening the properties on the parent project and selecting the following Project Facets:
Java
Dynamic Web Module
This solved the problem. My guess is that, because the parent project for a multi-module project has pom packaging (<packaging>pom</packaging>), Eclipse doesn't know what kind of projects the parent project encloses (i.e. if the packaging were jar, it would know that it's a java project; if the packaging were war, it would know that it's a static or dynamic web module, etc.)
This is just my guess, but the fix worked for me, and it makes sense.

for those who already see java selected, uncheck and check it again.
select apply to override the existing setttings. finally it works !
Right click your project > Properties > Project Facets > Convert to Faceted Form, and select Java

Right click your project > Maven > Update Project
This step will add your project so the issue resolves easily.

mvn eclipse:eclipse
will resolve this problem. convert to maven project.

I had this error because I tried to create a new Project by doing "Ctrl+N", typing "Project" on the Wizard's input label and then just pushing "Enter" until it was created.
I solved this by typing "Java Project" instead of just "Project".
You can also create a JAVA PROJECT by going to File > New > Java Project.

open cmd and run the following command in the folder of your project-
mvn eclipse:eclipse
This did the trick for me

If you are having maven project and you are getting this error. You can follow below steps.
Right click on the project and select properties.
Then click on Project Natures
In the dialogue box, click on Add and in the warning click on OK.
Filter java in the popup box and click on OK.
Click on apply and close.
It will add java nature to your maven project and you will not get this error anymore.

Right click your project > Properties > Project Facets > Convert to Faceted Form, select Java, and apply&close

Related

Spring-Boot application does not build properly

my problem is when I trying to run my spring-boot project via STS or simple JavaApplication the changes after the last maven build are not built.
I'm tried several methods but, if I don't use maven build the project changes are not rebuilt.
Do you have any tips, what's wrong?
In the Project menu Build Automatically is selected. And the main method is annotated with #SpringBootApplication
(The hot-swap is not working too for me.)
I think . do clean first then right click project Maven-> update Maven. do clean again. plz
I found the solution. In the .project file for my project I simply added a javabuilder build command. After that STS works perfectly and rebuilds the project before start. I think this problem occurs because I created a maven project, instead of creating a java project and convert it to a maven project.
If your project is gradle then go to Project right click and go to >gradle >Refresh gradle project.
Try to click ctrl +shift+O for import realated dependencies in your project.

why this eclipse error showing and what should be the solution for it

Missing library: xdoclet-1.2.1.jar. Select the home directory for XDoclet. 1.2.1
why this eclipse error showing and what should be the solution for it alz
It is causing possibly because that jar is not added to your project build path. Follow this steps:
Right click on project(in the package explorer)
-> Buid Path
-> Configure Build Path
-> Java Build Path
-> Libraries tab
-> Add JARs button
Then locate the folder where the jar resides. You can filter your search by typing *.jar in the search field. And then click ok.
I downloaded the xdoclet-lib-1.2.3.zip file from:
http://sourceforge.net/projects/xdoclet/files/xdoclet/1.2.3/
unziped it to its folder name, xdoclet-1.2.3, and then from the Eclipse (I was using 4.5) preferences JavaEE -> XDoclet tab selected the Version 1.2.3 and then the Browse button to the xdoclet-1.2.3 folder. Apply and OK and Eclipse error goes away.
Saying all that, I suspect you don't really need it unless you know that you are using xdoclet. If that's the case and it was intentionally left out then the error message should be fixed in Eclipse. I only went around fixing it because of the message.
If have maven version of the project, can also try by updating the project. I also had this XDoclet. 1.2.1.jar complaint, which got resolved once I update the project.
Right Click Project > Maven > Update Project ... > Check the projects > OK.
Please add maven dependency in your project . Steps are -
1- Right Click on Project
2- select configure build path
3- select library tab
4- add library and select Maven Dependencies
5- apply and Apply and Close .

I used m2eclipse plugins in eclipse.why the imported package still cannot be resolved by eclipse?

I get a mvn project , and to debug this project in eclipse,I imported the project into eclipse.But it's a pitty that some imported packages cannot be resolved by eclipse.Othes tell me that I should install m2eclipse plugin for eclipse, and run ""mvn eclipse:eclipse" to convert the project as a eclipse-like" project ,thus all packages will imported to eclipse build path automatically. Yes , I do so. And the eclipse build path is just like this
:
But it is extremely strange that eclipse still cannot resolve some import .
Any body can tell me what happened? From the build path ,I can see that eclipse have already imported the needed jar file for me.But it seems that the build path didn't take effect.
First of all, you're not using the m2e plugin; while it may be installed, it's not activated for this project:
There is no little "M" on the project's icon
The classpath doesn't include an entry org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER
From what I can see, Eclipse can't resolve the dependencies since the variable M2_REPO isn't defined (if it could, you would see the absolute path to the JARs in the upper image after the symbolic path).
To fix this, go to Preferences and search for "Classpath Variables". Add M2_REPO there with the correct path (default is $HOME/.m2/repository).
If it already exists, make sure the path is correct.
Alternatively, right click on project and select "Convert to Maven Project" under "Configuration".
How did u create a project. Try creating a web project. This template will provide the correct creation web application structure. It will also automatically add the required jars in the build path.
It is an eclipse problem (are you using the latest version?), try to run:
mvn eclipse:clean
mvn eclipse:eclipse
then open eclipse, refresh the project (right click on the project icon and select refresh),
clean it (Project > clean ...). It could be necessary to reconvert the project to maven
(right click on the project and convert it to maven project).
Sometimes closing the project (right click on the project icon > close project) and reopening it (double click on the icon) solves this issue.

How to build and run Maven projects after importing into Eclipse IDE

I am learning building a Java project in Eclipse using Maven. I created a Java project HelloWorld from
“maven-archetype-quickstart” template in a folder D:/maven_projects. Then to convert the Maven project to support Eclipse IDE, I navigated into the project folder and issued the commands:
mvn eclipse:eclipse and mvn package .
Then I imported the project in Eclipse and did the necessary Eclipse configurations like setting the Maven local repository in Eclipse classpath. Now the project in D:/EclipseWorkspace folder. I ran the project successfully in Eclipse printing "helloworld".
Now if I want to go on develop the project and for that reason want to add new dependencies in pom.xml in Eclipse, then the new jars are not added in classpath when I run the project.
So my question is after importing a Maven project into Eclipse how can I add more and more dependencies in pom.xml, then build and run the project? What is the recommended and efficient way to do this?
I would recommend you don't use the m2eclipse command line tools (i.e. mvn eclipse:eclipse) and instead use the built-in Maven support, known as m2e.
Delete your project from Eclipse, then run mvn eclipse:clean on your project to remove the m2eclipse project data. Finally, with a modern version of Eclipse, just do "Import > Maven > Existing project into workspace..." and select your pom.xml.
M2e will automatically manage your dependencies and download them as required. It also supports Maven builds through a new "Run as Maven build..." interface. It's rather nifty.
1.Update project
Right Click on your project maven > update project
2.Build project
Right Click on your project again. run as > Maven build
If you have not created a “Run configuration” yet, it will open a new configuration with some auto filled values.
You can change the name. "Base directory" will be a auto filled value for you. Keep it as it is. Give maven command to ”Goals” fields.
i.e, “clean install” for building purpose
Click apply
Click run.
3.Run project on tomcat
Right Click on your project again. run as > Run-Configuration.
It will open Run-Configuration window for you.
Right Click on “Maven Build” from the right side column and Select “New”.
It will open a blank configuration for you.
Change the name as you want. For the base directory field you can choose values using 3 buttons(workspace,FileSystem,Variables). You can also copy and paste the auto generated value from previously created Run-configuration. Give the Goals as “tomcat:run”. Click apply. Click run.
If you want to get more clear idea with snapshots use the following link.
Build and Run Maven project in Eclipse
(I hope this answer will help someone come after the topic of the question)
Dependencies can be updated by using "Maven --> Update Project.." in Eclipse using m2e plugin, after pom.xml file modification.
Just install the m2e plugin for Eclipse. Then a new command in Eclipse's Import statement will be added called "Import existing maven projects".
answer 1
Right click on your project in eclipse
go to maven -> Update Project
answer 2
simply press Alt+F5
after updating your pom.xml. This will build your project again and download all jar files
Right Click on your project
Go to Maven>Update Project
Check the Force Update of Snapshots/Releases Checkbox
Click Ok
That's all. You can see progression of build in left below corner.
When you add dependency in pom.xml , do a maven clean , and then maven build , it will add the jars into you project.
You can search dependency artifacts at http://mvnrepository.com/
And if it doesn't add jars it should give you errors which will mean that it is not able to fetch the jar, that could be due to broken repository or connection problems.
Well sometimes if it is one or two jars, better download them and add to build path , but with a lot of dependencies use maven.
If you are getting this error :in cucumber Exception
Cucumber Exception: java.lang.ClassNotFoundException:
cucumber.io.ResourceLoader :
then add following jar file to your pom.xml
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-core</artifactId>
<version>1.1.8</version>
</dependency>
Run the maven build once and should be gone

How to achieve that Eclipse clean and build (aka rebuild)?

I deleted my ./bin folder in an Eclipse Indigo (super similar to Helios), and now I am wondering how to rebuild my Java project. I just cannot find a button like we can see in Netbeans.
For Eclipse you can find the rebuild option under Project > Clean and then select the project you want to clean up... that's all.
This will build your project and create a new bin folder.
In Eclipse there is an "Auto Build" option, which is checked by default. When it is checked, you don't need to build your project, this happens automatically. If this behaviour is unwanted, uncheck this option and click build project whenever you want.
To clean a project, select Clean Project. This will delete the bin folder, however if Auto build is checked, it will be immediatelly regenerated.
In case you are unable to find a file in Eclipse code after pulling code from git or creating a file in intelliJ seperately (my case) you ca do the following
Right click on 'src' folder and in the menu that appear click on the 'refresh' button

Categories