Eclipse Java Missing required source folder: 'src' - java

I imported a jar file into workspace and this is the error I get:
Description Resource Path Location Type
Project 'Interpreter1' is missing required source folder: 'src' Interpreter1 Build path Build Path Problem
How can i get rid of this error?

Right-Click Project --> Build Path --> Configure Build Path; unselect the SRC, save, select again.
This solved my problem.

Go to the Build Path dialog (right-click project > Build Path > Configure Build Path) and make sure you have the correct source folder listed, and make sure it exists.
The source folder is the one that holds your sources, usuglaly in the form: project/src/com/yourpackage/...

Right Click Project -> New -> Folder -> Folder Name: src -> Finish

Here's what worked for me: right click the project-> source -> format
After that just drag and drop the source folder into eclipse under the project and select link.
good luck!

Edit your .classpath file. (Or via the project build path).

Right-Click Project --> Build Path --> Configure Build Path-->source-->(Select missing folder or path)-->Add Folder-->Apply-->Ok

Create the src folder in the project.

I was confused by this for hours.
Right click on project -> Build Path -> Configure Build Path -> Add Folder

One of the build path issue is it cannot find the correct /src/conf source folder. Right click on each project, Build Path > Configure Build Path. Under the Source tab, remove the folder with a red cross icon on the bottom right. It will work for the situation that there is a small red exclamation mark “!“ bedore your project name!

In eclipse, you must be careful to create a "source folder" (File->New->Source Folder). This way, it's automatically on your classpath, and, more importantly, Eclipse knows that these are compilable files. It's picky that way.

If you are facing an error with the folder, such as src/test/java or src/test/resources, just do a right click on the folder and then create a a new folder with the name being src/test/java. This should solve your problem.

I think it's because of the .classpath getting saved with the deleted source folder configuration.
Create the missing folder [ 'src' in your case] manually inside the root of the project. When I say manually, I meant outside Eclipse, using the file explorer.
Then, come back to eclipse and refresh the project. Now, the error saying it's already there will be gone.
Now, Right click on the project > Build Path > Configure Build path. It should take us to the Java build path side menu.
Make sure we are on the 'Source' tab. Delete the source folder causing the problem. Now, maybe the folder might show up in the project structure and you may delete that too.

Eclipse wouldn't let me point to an existing (or add a new) source directory.
Eclipse's configuration files can be wonky. In my case I should have started simple. Right click the project and click Refresh.

In my case eclipse reported this in the Problems view on the parent project which does not have any code. I just delete the error whenever it is reported on this parent project where src folder is really not needed.

Related

My src in Java Resources suddenly disappear

Im creating a Dynamic Web Project, and I have src in my Java Resources then suddenly src disappear inside of it. I find out that the src became a context folder in the root along with Java Resources, Build, WEB-INF and WebContent folders. Why this happened. Sorry for bad grammar. Thanks in advance.
Verify your java build path of the project and check if src is present there.
Right click on the project and select Build Path -> Configure Build Path.If src is not in build path it won't show you can add src folder in your build path of the project by following below steps,
right click on project
select properties
select java build path
goto source tab
click add folder
select your source folder (src/main/java)
Also look at perspective is will be in Navigator perspective.
In your IDE goto Windows-> Show View -> Navigator, check the image for the same try to change it to "navigator" view your will be able to see it. If not please share the images of it, then we will help you more
#msagala you have to Configure build path. Then under Source tab click Add button and you will see your existing source folder.
I hope this will help you.

Build path entry is missing: /src/test/java

While running my java project on Eclipse Luna, I have some errors due to which I suppose related to this problem.I right click on the project, choose properties --> java build path --> source, I see a warning at the top:
And it seems that I have forgotten to add this package at the beginning of my project.I want to add it now, but I cannot do it via "Add Folder" button.When I press "Add Folder" button, a window appears like this one:
However, I believe I should add it under "Java Resources" on the tree:
How can I modify this?
Thanks for any help..
src/test/java is just maven's default entry for any test classes. If you have (or plan to have) test classes, you can create a new folder structure test/java below your src folder and afterwards select it in the dialog you've shown. If you don't plan to have any test classes, you can safely remove the entry from the build path.
This worked for me:
mvn clean install
How to add missing src/test/java folder to the maven project in Eclipse
1) Create a folder test/java under src folder
2) Right click on the project and choose Maven --> Update Project --> choose for Force update of Snapshot/Releases and click ok. Now test folder should appear as src/test/java in Eclipse project explorer

Creating a src/main/java folder structure in Eclipse without Maven

How do I create the src/main/java and src/test/java in my default web application project in Eclipse without Maven? My current folder structure is
TestApp
├── JavaResources
│ └── src
│ └── com.mypackage
└── WebContent
As you've discovered, you can't have a source folder inside another source folder, so before you can create src/main/java you have to tell Eclipse not to treat src as a source folder. To do this, right click on the src folder and select build path -> remove from build path.
Once you have done this src will appear in the folder tree in its normal place, so you can create the main and java folders under it, and move the existing src/com to src/main/java/com. Finally right-click the newly-created java folder and select build path -> use as source folder.
I have solved this issue by below steps:
Right click the Maven Project -> Build Path -> Configure Build Path
In Order and Export tab, you can see the message like '2 build path entries are missing'
Now select 'JRE System Library' and 'Maven Dependencies' checkbox
Click OK
Open Properties > Java Build Path for the project. Select the Source tab and use Add Folders to add source folders.
Remove the actual source folder definition in the build path and add a new source folder an name it src/main/java
If the package structure is setup as src.main.java.com.inventica, instead of com.inventica, that’s usually because under project properties > Java build path > Source, the source folder is setup as src instead of src/main/java. There’s no easy way to fix this, so remove src as a source folder and click ok.
Now Eclipse will show a folder hierarchy src/main/java. Browse to the java folder > right-click > build path > use as source folder.
After this, you may have to fix the Eclipse .project and .classpath files to have it use Maven to manage dependencies, builds etc.
Typically, you can copy this from a working project since there isn’t anything project specific here assuming you’re structured as a standard Maven project.
the problem will be solved by checking on 'JRE System Library' and 'Maven Dependencies' checkboxs Click OK. this is found in the project's 'build path option'
If you don't find the Included Path just add the path it will resolve.
Solution One:
Change the JRE version to 1.8 and change it back to the original version (for maven-archetype-webapp, the original version is 1.7).
Solution Two:
Check the JRE option and Maven Dependencies option in "Order and Export".
Simple solution would be create 'java' folder directly one the drive into src/main even before opening it in eclipse that way eclipse will not complain about the issue.

How to deal with missing src/test/java source folder in Android/Maven project?

I'm not very experienced with Maven in combination with Android yet, so I followed these instructions to make a new Android project. When the project has been created, I get the following error message:
Project 'xxx-1.0-SNAPSHOT' is missing required source folder:
'src/test/java'
When I try to add a new source folder with New->Other->Java-Source Folder with src/test/java, I get another error message:
The folder is already a source folder.
But I don't have any src/test/java folder in my project. How should I deal with that? What's the clean way to setup the project, because I assume that there is something missing in this instruction. So what is the Maven way to let src/test/java appear?
I'm using Eclipse Juno, m2e 1.1.0, Android Configuration for m2e 0.4.2.
I realise this annoying thing too since latest m2e-android plugin upgrade (version 0.4.2), it happens in both new project creation and existing project import (if you don't use src/test/java).
It looks like m2e-android (or perhaps m2e) now always trying to add src/test/java as a source folder, regardless of whether it is actually existed in your project directory, in the .classpath file:
<classpathentry kind="src" output="bin/classes" path="src/test/java">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
As it is already added in the project metadata file, so if you trying to add the source folder via Eclipse, Eclipse will complain that the classpathentry is already exist:
There are several ways to fix it, the easiest is manually create src/test/java directory in the file system, then refresh your project by press F5 and run Maven -> Update Project (Right click project, choose Maven -> Update Project...), this should fix the missing required source folder: 'src/test/java' error.
We can add java folder from
Build Path -> Source.
click on Add Folder.
Select main as the container.
click on Create Folder.
Enter Folder name as java.
Click on Finish
It works fine.
I solve the problem by creating a folder named "src/test/resources" first, then i rename the folder to "src/test/java" ,finally create a "src/test/resources" folder again .It works .
This is possibly caused due to lost source directory.
Right click on the folder src -> Change to Source Folder
I had the same issue, fixed it.
Create the missing folder directly in your file system (Using windows explorer for example) .
And then, refresh your project under eclipse.
This is a bug in the Android Connector for M2E (m2e-android) that was recently fixed:
https://github.com/rgladwell/m2e-android/commit/2b490f900153cd34fff1cec47fe5aeffabe44d87
This fix has been merged and will be available with the next release. In the meantime you can test the new fix by installing from the following update site:
http://rgladwell.github.com/m2e-android/updates/master/
In the case of Maven project
Try right click on the project then select Maven -> Update Project... then Ok
Removing the m2 plugin from startup-up plugin's list and doing a Maven->Update Projects on all the projects worked for me.
Note** One should not create additional folders to avoid merging them while using SVN/Git based branches.
Select project -> New -> Folder (not source folder) -> Select the project again -> Enter the folder name as (src/test/java) -> finish. That's it.
If the test source is missing, it would link it automatically. If not, then require to link it manually.
Fixing this issue is really very simple, Just Right Click on the project go to Properties. After that go to Build Path, You see an error like ” 2 build path entries are missing “ This error usually comes when the JRE System Library is wrongly pointed. Now go to the Libraries tab and change the JRE System Library to the correct version by clicking on Edit.
Here is the complete Tutorial:
https://kkjavatutorials.com/how-to-fix-missing-src-main-java-src-test-java-folders-in-the-eclipse-maven-web-project/

how to recover a corrupt workspace in eclipse?

I had a corrupt workspace (due to svn collision).
I deleted the .metadata directory from the workspace, and then reloaded eclipse, and did an "import" of a project into the workspace.
However, the project got imported in a rather strange way -- all directories in the project appear, but the src/ directory does not have automatic compilation (when choosing a .java file) -- it is as if the src/ directory is not identified as a special directory.
Is there a way to fix that?
I also followed http://letsgetdugg.com/2009/04/19/recovering-a-corrupt-eclipse-workspace/, and that did not help either.
Switch to a new workspace.
Then go File -> Import -> Exsisting projects into workspace .
In the root folder text box , type the address of corrupted workspace.
Click Refresh .
Select the projects and click finish
All configuration data for your workspace is stored in .metadata. Try to recover the deleted folder then fix the workspace. Otherwise you will need to reconfigure everything.
You can salvage certain folders from .metadata to keep your preferences (e.g. key bindings) at least.
After importing your project, check your project properties, especially the entries in "Java Build Path". There you have to add the "src" directory as source folder. Maybe you also have to adjust the output folder and libraries you are using in your project.
create a new project.
copy your pages ,library files,etc.
set build paths.
compile it. then others will be automatically created
copy project to another (right click -> copy in eclipse)
new project created was correct for me in same situation and .class files repair .

Categories