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.
Related
sometimes i face project structures in Package Explorer that are at "src/main/java". But if i work for myself it is only "src". Howto take controll of that?
Difference between two projects in eclipse: left: one folder named "src/main/java" right: one folder named "src", one subfolder named "main.java"
Thanks - Enomine
The default source folder for a Java Maven project is src/main/java. In the project on the right, the source folder is set to src via the following line in the pom.xml file:
<sourceDirectory>src</sourceDirectory>
If you remove the line or change the value, right-click the project and choose Maven > Update Project... to have Eclipse read the pom.xml file and update the source folder location accordingly.
Difference: Let's first understand the meaning of both the folders. In the left image src/main/java is the source folder which is used by eclipse to build the project. In the right image src is the source folder with the package main.java
Solution: It is not possible to edit your source folder So you have to copy your files and create a new source folder with name src/main/java.
#howlger
Project structure and pom
I think i did right now. I clicked right, choosed "Build Path" -> "New Source Folder". Then it worked. With the Properties-Menue "Java Build Path" it didn't work.
Thanks - Enomine
The projects with src/main/java as source folder are maven projects. Maven is a build infrastructure which i.a. manages library dependencies, and provides conventions for the project folders, like src/test/java for unit test sources, and src/main/resources for non-java sources like images and *.properties files.
Best would be to import the project as maven project (here it is not gradle). It might be that you need a plugin in eclipse; for a while I am using an other IDE.
Create a new maven as trial.
Maven projects are controlled by a pom.xml so a recognition as maven project is best.
In my opinion, there are two ways how to solve it:
1. go to project -> build path -> configure build path -> Java build path and then in source tab add your src/main/java folder
2. There is also an arrow near the "Project explorer" which lets you customize your workspace. you can try to change "project presentation" or "package presentation"
I installed jRebel on Netbeans 7.4 beta one day, the next day all my source folders an libraries to disappeared from my projects - except Maven ones. Like this:
The source folders are still present on my drive:
I just need to restore their visibility in my opened Netbeans projects.
When I try to add source packages from the "Properties" menu of the project, I do get the source back but as folders, not packages.
Help would be much appreciated!
Try going to Files view in Neteans, and look under the src folder in your project. Does the src folder have a sub-folder named java?
If not, create it (right click on src, go to New, select Folder). Your source packages should re-appear in the project view.
This is for Netbeans 8.0. I am not sure if it is available for other versions.
Right click on the project -> Set Configuration -> Customize -> Sources -> Add Folder for Sources Packages Folder -> Select folders you want to see under your project -> OK
Netbeans version 8:
In files tab, go to main folder and create a folder called java. That's it!
How to include (NOT ONLY reference) JAR file into existing project? I added it by using Project properties - Build path - add external jar's. But when I export my project, and then import it in another computer, this library was missing.
Drag it into your project view so it appears in the project as any other file.
Right-click the jar in the project view and add to build path.
Put your jars into a directory of your project e.g yourproject/lib so that external libraries are accessed through a relative path. And then use "Add JARs" option to add the jar to build path as in eboix's link.
You want to export your project as an archive (Export -> General -> Archive File), and then import your project as an existing project (Import -> General -> Existing Projects into Workspace). This way the project will be identical to the exported version and all of the configuration will be right.
Oh, and do what the other people suggest and copy the Jar file into the project so you don't have to reference it as an external Jar file (and everything is in one place).
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.
I am new to Eclipse IDE, I created a new project named "Hello World", and I need some APIs which are contained in a jar file.
I created a folder called "lib" under the project folder "Hello World" (parallel with src folder), and I import the .jar file into this lib folder, it extracts all the things to this lib folder automatically.
Then I created my HelloWorld.java class under src folder, however, when I put import ro.xxx.xxx.xxx, eclipse complains "the import ro cannot be resolved". Actually, the ro is under the lib folder.
I am stuck here. Shall I make this lib folder under the src folder instead of parallel with it? Please kindly give me some suggestions, thanks in advance!
Project -> properties -> Java build path -> libraries -> add external jars
Just Putting jar in lib folder won't work , you need those jars in your class path.
Here it is described how to add jars in to your build path in eclipse
Add the library to your build path.
Right mouse button on your project --> Build Path --> Configure Build Path...
Libraries --> Add jar
After you first create the lib folder parallel to the src folder you need to go back into Eclipse and Refresh the project so that Eclipse finds the new folder and jars. You can either highlight the project and hit F5, or use the right click menu off the project. After that the lib folder and jar files appear and you can right click a jar to add to the build path. If you add new jars subsequently you need to refresh again for Eclipse to find them.