Eclipse : Project properties don't show Build Path - eclipse

My Eclipse does not show the 'Java Build Path' option in my Java project's properties. The properties screenshot is attached below. What might be the reason for this? On the left side there should be an option for 'Java Build Path'.

To resolve this issue follow the below options
1) Go to Project root
2) Select "Project facets" from Properties
3) Check "Java"
This fixes the issue

I was in the same situation, and found two different solutions for this.
Right click on the src folder and check if you can see the option to configure the build path. After that, right click on the project and do Maven > update project.
If this does not work,
Right click on the project > properties > project facets and click on the link saying convert the project into faceted project.
Right click on the project, hit Refresh and check if you get the option to configure build path now.

You may get some help from any of these blogs
How do I add a builder to a given project
OR check this post
Eclipse adding your own build command

Build your project using Project->Build Project in Eclipse .This will automatically adds build path to your project.

I had to delete my maven .m2/repository folder and that made my build path reappear.

I had the same problem when trying to compile a project. The solution was to go to "run configurations" and choose the right Runtime JRE.

Make sure your project's root directory contains .classpath and .project file.
The .classpath file should look like this -
The .project file should look like this -
With these changes in place you should be able to see the proper folder structure as well as the "Build Path" option when you right-click the project.

If it was working fine previously and now its not, check whether you are in Enterprise tab or the Navigator tab, because if you're in the Navigator tab it won't work.

Related

Eclipse can't create package and instead it creates a folder

Environment
Eclipse Mars 4.5.0
I'm trying to create a package with name com.javalabs.web.action but instead of that Eclipse created a folder inside com.javalabs.web.
As you can see in the following picture, the icon is not the same that, for example actions.
The problem seems to be only with the name action, because a could do that with actions and other names.
I don't care about the package icon, but the big issue is that Eclipse doesn't recognise de classes inside that folder as their classpath.
Any idea of what can be?
Click on 'src' folder and refresh. There you go..
Check the "Resource Filters" configured for your project (you can find them as a child of the "Resources" entry in the project properties).
The next set of filters is in the "Java Build Path" where you can configure exclude patterns per source folder.
That's what I did step by step to solve the problem:
Right click on Project Folder > Properties > "Java Build Path"
Select source folder where you are creating the package
Double click on "Excluded" under the folder you want changes
Edit
Under Exclusions patterns > remove everything you need to include specially remove the **
Finish
Apply

Eclipse+Maven src/main/java not visible in src folder in Package Explorer

I'm wondering why I can't see following folders in src node in Package Explorer
src/main/java
src/main/resources
src/test/java
src/test/resources
I can access those folders as direct children of the project and they exist in the file system.
I'm using Spring Tool Suite (STS of Eclipse).
Maybe I can configure Eclipse somehow ?
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
Now you can see below in all type of Explorers (Package or Project or Navigator)
src/main/java
src/main/resources
src/test/java
Eclipse filters out folders that are marked as source from the "raw" folder path. That is, they are visible only as source folders:
If you can't see them in either place, then they
are either filtered out in the settings: check your settings for Package Explorer (the Package Explorer bar, downwards menu arrow -> Filters...)
or they were created externally and Eclipse haven't noticed them: Refresh your project in this case.
or they don't exist: right-click on the project, select New->Folder and input the path, e.g. src/test/java (not "Source Folder"). After you use Maven->Update Project... on the project, they will be automatically added as source folders, provided you have the default configuration.
Now, as I said, those folder will only be used as source if you preserved the default configuration in your POM. If you defined other resources and/or testResources, those will be used instead. In general, Eclipse m2e synchronizes Eclipse's project source folder configuration with what's in your POM.
EDIT: maybe this is unclear - see those folders at the top? The ones labeled with the /-separated paths? These are your folders. These are the same folders that you would expect to find in main and test, just represented differently.
I used to get the same problem, but solved it by pointing to the right jre used for the project.
Right click on the project
properties
java builpath
see the jre selected
edit it
select alternate jre
installed jre
select the right one
ok
After changing right click on project>maven>update project
Hope it helps.
Attaching screen shot.
If you are looking for Simple/quicker way, you can follow this solution.
Right click on your project.
Goto > Build Path > Configure Build Path > Java Build Path
Goto 'Source' tab, there, you can see like <<your_project_name>>/src/main/java(missing).
Click on it and remove.
Click on Apply and Close.
Now, right click on project and >New > Source folder > add source folder "src/main/java".
happy learning and do not forget to upvote :)
I had the same problem, I changed my Eclipse project view from Package explorer to Project Explorer.
After 2 hours of trying everything...
Just go on window -> show view -> project explorer
and in project explorer you can view of all files solution
I had a similar issue when I checked out a web project from a github repo on my eclipse. src/main/java was directly inside the project root in Package Explorer. My expectation was that src/main/java be visible inside a source folder "Java Resources". There were few things which I did to achieve this.
Right click on Project > Build Path > Configure Build Path..
Select filter "Java Build Path" and click on Tab "Libraries"
Verify your "JRE System Library". If it is not pointing to your latest JDK, then you can click on Edit Button and follow the subsequent dialog boxes to select most appropriate JDK home path in your system.
Once done click Apply, Apply and Close, Finish to close all the associated open boxes for the current filter.
Select filter "Java Compiler" and ensure your JDK Compliance points to correct JDK. Click Aapply
Select filter "Project Facets". Ensure both Java and Dynamic Web Module is selected with correct version.
Click Apply and Close.
Source folder "Java Resources" gets created with src/main/java in it when viewed in Project Explorer.
Navigate > Show In > Package Explore
Right click the Maven Project
-> Build Path -> Configure Build Path
Go to 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
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
Now you can see below in all type of Explorers (Package or Project or Navigator)
I used this tutorial to create my maven web project http://crunchify.com/how-to-create-dynamic-web-project-using-maven-in-eclipse/ and eclipse did not create src/main/java folder for me. When i tired to create the source folder src/main/java eclipse did not let me. So i created the folder outside eclipse in the project directly and then src/main/java appeared in eclipse.
I was not able to see the build path option in the properties as well. Also the
src/main/java
was not visible in Project Explorer. below solution worked for me
Go to Project root
Select "Project facets" from Properties
Check "Java"
This fixes the issue
If none of the answers worked for you. You might be in the wrong "Window". I was in "Package explorer" and switching to "Project Explorer" showed me the folders.
Right click on the project > Build Path > Configure Build Path > Source > Add Folder > Select src/main/java > apply and close > refresh the project.
This error happens when there are no files inside /src/main/java
Just make some empty files inside and the problem will go away.
A side note: lots of version control systems (mercurial for example) do not commit folders if there are no files inside.
After creating the project go to properties --> build path --> configure build path --> order and export tab and check jre and maven dependencies. You will then have the folder.
Right click on eclipse project go to build path and then configure build path you will see jre and maven will be unchecked check both of them and your error will be solved
My problem was kind of the same at first and then a little different in the sense that when /java folder showed up, it was deep down in a nested folder somewhere in src/main/resources/java.
Initallially the problem was being in the Package Explorer and not in the Project Explorer as many people have talked about. So,
a. right-click on your project root
b. show in, and select Project Explorer
However, the main problem was I missed to notice a checkbox at the second step of Maven Project Creation from the wizard. That got me created a complicated structure and not a clean direct one.
Once I marked it checked I got a clean project structure as what asked.
I was also facing the issue but I open POM xml file and keep it open. Wait for some time till maven read pom then Automatically it will come.
I tried all the solutions mentioned in this post but none of them worked for me.
The solution for me was to go to build-path and then into Source tab. I found src/main/java folders present there and there was no error. I double clicked on this folder and a window opened like this:
Do not make any change and click on Finish. The folders will appear suddenly.

.class file opens instead of .java while debugging

Current setup:
MainProject which is a Library Project
BranchProject which is a new projects and has MainProject as a Reference
Whenever I debug and a file from MainProject is on focus (actually BranchProject has only graphic and xml layout changes) the Debug window opens a .class file which is read only. I want it to open the .java file so I can edit it directly.
Skyler's answer from this post worked for me:
Opening source code from debug view edits .class after Android R18 update
Here is a summary:
The fix is to right click the Project name in the debug view, and select "Edit Source Lookup..." from the menu. From there, remove the Default lookup path. After that, manually add the associated projects (not jars) that your project references. This is done by clicking Add, selecting Java Project, then checking the appropriate projects.
When you're using a Library project one of the things you're in fact doing is compiling your Library project into a jar and then referencing that jar in your calling Project.
If you right click the Project, and select "Configure Build Path" you'll see a tab called "Libraries", if you look inside "Android Dependencies" you'll notice a list of jar's corresponding to your Library projects.
These jars are expandable, showing you that they have a slot for a source attachment. Usually this would be editable allowing you to directly link the source but in terms of ADT these are already filled and are uneditable.
When debugging these files you're linked to a read-only class file with this attached source. This is because you're not running against source files directly, you're running against a pre-compiled class file. Until the ADT team get this functionality in place, you're pretty much forced to jump to the direct source code and rebuild everything.
EDIT
See #Steven linked answer :)
I faced the same issue while debugging the a .java file using Eclipse IDE. As per my understanding this issue comes when we put the xyz.class file of xyz.java file or JAR at the project build path. Delete the .class or JAR file from the project class path and rerun .java file in the debug mode. This time you see a source not found window. Click on "Source not found" button and check "Find duplicates..." at the bottom of the window. Done your problem is solved :)
The problem is that the class file is preferred over the java (by default), here is how you can change that for Eclipse (tested on NEON 2):
Right-click on the Project in the Project-Explorer, click Properties
On the new window select: Run/Debug Settings
Create a new configuration (or duplicate another one)
Select the new config and click Edit...
Go to the tab Source
Select the Default and Remove
Create a new path with Add..., select Java Library, then JRE System Library
Create a new path with Add..., select the location where the sourcecode is by Workspace folder (if it is a project in the same workspace) or File System directory (it it is not)
I think this depends on, how you set up the dependency in eclipse. You should set up your BranchProject to depend on the source-Files of your MainProject. If you depend on compiles Class-Files is obvious that the debugger opens the class files, because it does not know about the source files.
I found a good solution for me here:
Using Android library in eclipse and jumping to class files instead of source file that is within eclipse workspace
Simply, select each library project your project depends on, and use Top or Up to move it above the projects outputs. Eg. move all library projects to the top.
Open main project properties -> Java Build Path -> Projects tab and add there projects the main project depend on.
Switch to Order and Export tab and uncheck Android Dependencies
Enjoy
If you tried all above hints and it still doesn't work try this solution, it worked form me:
Right-click on the Project in the Package-Explorer, click Build Path -> Configure Build Path...
Select tab Order and Export
select library that you can't reach code and then click on button Bottom
Then click on Apply and Close
hope this can help you
Most of the time it happens when specific source folder are not added in build path Sources tab.
Right-click on the Project in the Package-Explorer, click Build Path -> Configure Build Path -> Source Tab
Add the source folder if your project source folder is not there.
Select Add folder -> select your project source folder specifically. Eg: project_name/src . Then Apply it and restart server.

In Eclipse folders appear as packages

I'm getting an issue where non-src folders are looking like packages, they look completely fine in my natural folder directory.
The assets folder should be a hierarchy, but isn't.
Thought it was because I was in package explorer but not project explorer, same issue with project explorer.
I believe, you right click on your project and choose "Build Path" and "Use as source folder". If it is the case, you can revert the problem by right clicking on your project and selecting "Build Path" and then "Remove from build path".
For me the following worked (in RAD actually): Go to "Project Properties" / "Java Build Path" and mark the Resource Folder as "Source folders on the build path".
The Resource Folder (here, src/main/resources) appears as filled with classless packages:
Enter the exlcusion pattern "**" to exclude any source path:
This solves the problem.
Maven Update fixed my problem easily.
Right click on project,
maven->Update Project
I suspect that the cause was I run maven commands from command prompt (cmd) directly.
If your simple folder is turning into package format. Be clear that it is not source folder, it is just simple directory like "docs" you want to keep in your Project but eclipse is turning it into Package format. then do below step:
right click on your package -> Build Path -> exclude

m2eclipse, subclipse - Checking out web application

In the SVN repository browser I can right click on 'trunk' which gives me the option to 'checkout as maven project'. I have two problems:
When it checks out the project, it is giving it the directory structure mavenxxxx > trunk > src. How do I configure this so it is MyProjectName > src and skip the trunk folder and only check out it's contents?
When I check out my project it appears as a java project when I want it to be a web application project, is it supposed to be picking up that it is a web application from my pom file, or do I have to follow any other additional steps to configure it?
Thanks
Check Out From SVN
It sounds like you are not selecting the "trunk" folder when you checkout your project. If your project name is Mavenxxxx and you select 'Mavenxxxx" when you check out, then you will get see the behavior you've described.
In your post, you said you did, in fact, right-click on "trunk." So I would suggest checking out your project another way. Try this:
File > New > Other...
Type "SVN"
Select "Project from SVN"
Click "Next" then choose/create your repository and click "Next"
Click Browse... and navigate to your project
Highlight the "trunk" folder and click "Ok" then click "Finish"
In the popup window, choose "Check out project with the name specified"
Click "Finish"
If that doesn't work, then there must be folder at the root level of your project named "trunk." As in Mavenxxxx > trunk > trunk.
Enable Web Application Project
To answer your question:
...is it supposed to be picking up that it is a web application from my
pom file, or do I have to follow any other additional steps to
configure it?
What you are trying to do is change the nature of your project. That can't be done from the POM file.
Instead, right click your project, go to the "Project Facets" section.
That is where you should be able to set it as a web application project.
If you see a link that says, "convert to faceted form..." then do that. Next, choose the facet related to WebApps. I don't have my eclipse setup for Web Application projects so I can't tell you the exact wording that you'll see. I think you need the Eclipse IDE for Java Developers to see that and I have the J2EE version.
I hope that helps...
You mentioned that you're using Subclipse, I highly recommend using Subversive SVN Team Provider over Subclipse. gmale's instructions should work from that point on.