I have my source in the hierarchy:
folder: src/main/java
package: com.test.serviceImpl
Now eclipse is showing this as src.main.java.com.test.serviceImpl
How can I make it display only com.test.serviceImpl under the directory structure : src/main/java
Note: This is a maven project module imported to eclise. All other modules display properly
If you use m2eclipse and your pom is configured properly, just right-click the project and select Maven > Update Project Configuration.
If that doesn't work, study the Eclipse Maven Console (in the Console view) for errors.
Set src/main/java as a source root directory.
Here's the standard Maven directory structure - like it or not:
http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html
I had a problem which may be related.
Eclipse started showing folder names as a concatenation of the folder name with other elements. A folder named "x" was being replaced with "xorg.eclipse.jdt.core.javabuilderorg.eclipse.m2e.core.maven2builder"
After exploring various possible explanations and/or solutions, I realized this behavior appeared after my having deleted a project folder without checking the box "Delete project contents on disk (cannot be redone)". When I subsequently re-checked out the code from an SVN repository, a folder named "x" was still on my disk, and so I suspect Eclipse created a longer version of a folder to contain "x" using other elements from the buildSpec.
I fixed the problem by closing Eclipse, deleting both folders ("x" and "xorg.eclipse..."), reopening Eclipse and checking out the project again.
I had the same problem on my Maven project and I solved it just updating my project Maven>Update Project
Related
After creating the Maven Project in Eclipse from maven-archetype-webapp archetype i have the src/main/java not seen in project explorer and advices from same topic here do not work, so it is not a duplicate, because:
in my effective POM already stays :
<sourceDirectory>X:\Programming\workspaceEclipse\TomkatFromArchetype\src\main\java</sourceDirectory>
<scriptSourceDirectory>X:\Programming\workspaceEclipse\TomkatFromArchetype\src\main\scripts</scriptSourceDirectory>
<testSourceDirectory>X:\Programming\workspaceEclipse\TomkatFromArchetype\src\test\java</testSourceDirectory>
<outputDirectory>X:\Programming\workspaceEclipse\TomkatFromArchetype\target\classes</outputDirectory>
<testOutputDirectory>X:\Programming\workspaceEclipse\TomkatFromArchetype\target\test-classes</testOutputDirectory>
what is actualy ok.
But after updating maven, installing, building - whatever, i can not get the damn src/main/java shown in the project explorer and can create new java classes only in src/main/ressources.
I want generally know what is the reason for that behaviour, options for folders in m2E, so i could turn it and configure in different ways manually.
Some more info:
The folder src/main/java is sort of "exist", because if i try to create the folder, it shows that there is one with this name, but is not seen.
Opening project properties (right click) -> java build path ,stays
src/main/java and src/test/java (missing), how can it be?
Solved by looking in the file explorer, is the path realy there.
If it is there,it may be added in project explorer menu. If not - you create it in file explorer and add in project explorer menu
this issue occur into eclipse many time. you need to go to Project property > project facets and click on convert to faceted from.. then apply and ok. after this you can see the src/java/main into your project resources. you can fine image below:
One solution that could work in this scenario(suddenly src main java folder vanishes) is :
delete the project from the workspace. (not from disk)
re-import the project again as Maven project.
This worked in my case.
I'm using Maven 3.3.3 together with Eclipse Mars and m2e. Yesterday, I created a new Java project and converted it into a Maven one.
Afterwards, the classpath contained only src instead of the standard src/main/java. I was surprised but I simply created the missing folders and ran m2e's "Update Project". This didn't solve the problem; m2e still insisted on using only src.
So I edited the classpath manually to end up with with the usual
src/test/java
src/test/resources
src/main/java
src/main/resources
When I try m2e's "Update Project" now, I get this error:
Cannot nest 'foo/src/test/java' inside 'foo/src'. To enable the nesting, exclude 'test/' from 'foo/src'
sigh I went to the command line next and ran mvn eclipse:eclipse to get this classpath:
src/test/java
src/test/resources
src
src/main/resources
Now, I'm completely stumped. Why is that happening?
Open your POM in the POM editor and click on the "Effective POM" tab. Search for sourceDirectory. You'll probably see something like this:
<sourceDirectory>src</sourceDirectory>
When you first converted the Java project to Maven, m2e tried to keep the classpath the same. Eclipse Java projects have a different layout by default. They use src/ instead of src/main/java/. There is no test folder since Eclipse projects usually put their tests into a different project.
To fix the issue:
Delete the sourceDirectory element from the POM (Note: It might be in a parent POM).
Go to the project
Select all the source folders
Remove them from the build path (context menu -> Build Path -> Remove From Build Path).
Update the project
The error should now be gone and the classpath should be correct.
There are two types of folders that you can create: 1) Package 2) Source Folder
1) A package looks like this
To create a package, right click on the folder you want (in my example, I right clicked on Java Resources) --> New --> Package
A pop up window that looks like this should appear
“Source folder:” That is where you choose your project. If you don’t see anything there, click on “Browse…” and find your project. If I click “Browse…” it shows this:
“Name:” is the name you will give your package.
Note: Packages should be within Source Folders. Source Folders are the parent folder.
2) Source Folders look like this:
To create a Source Folder, right click on the folder you want (in my example, I right clicked on Java Resources) --> New --> Source Folder
Under “Project name:” write your project’s name. If you need help, click “Browse…”
Under “Folder name:” write the folder name you want.
Error: If you’re trying to create a “src/main/resources” folder and you’re running into this error “Cannot nest ‘ProjectName’ inside ‘ProjectName’. To enable the nesting exclude ‘main/’ from
Solution:
I am using Eclipse Indigo, and after having successfully extracted my project folder into my Eclipse workspace, it does not show up in the package explorer. I tried refreshing eclipse and restarting it, to no avail. I am 100% certain my eclipse is using the right directory and the project is in it.
What could be the problem? Thank you.
EDIT: "import projects into workspace" worked for me, but why was that necessary?
Files in the directory are not automatically picked up by the package explorer. You need to import them.
Try using the File > import, then choose
Existing Projects into workspace.
There is a checkbox that says "Copy projects into workspace" which copies it to your workspace if it happens to be in a different folder. If you start with your files in another folder, you'll see how it's copied and set up with configuration files in your workspace directory.
To answer the question, "why is it necessary to import?" you have to realize that the Eclipse workspace is just a logical container for projects, not necessarily the physical container for them.
Also realize that a directory of project-related files does not make an Eclipse Project; Eclipse must be given or generate it's own set of configuration in order to understand a project (minimally, for Java projects, .project and .classpath). Without those, Eclipse has no idea what to do with an arbitrary folder that you call a "project." That's what the Import or Create Project wizards are doing under the covers, generating those config files.
I have imported my maven project in eclipse using Import Maven project. It got import in eclipse project explorer, but all the source folder are opening as files and folders, its not opening as java source folder. Since its opening as files and folder, it doesnot have compilation unit, found very difficult to code using it.
What do I need to do inorder to make the source folder as java source folder so that I can code easily?
Select the project and from the context menu choose Maven -> Update Project Configuration (This menu item gets reworded across various maven releases so look for something similar). You may also need to choose Update Dependencies.
In the shell/command line, execute mvn eclipse:eclipse
Should renaming a project in Eclipse also rename project folder on file system ?
My project file system name remains the same even when I rename the file on Eclipse.
Should I manually rename the project on the file system to same on Eclipse ?
It appears that renaming a project will only rename the underlying filesystem directory if the project was created with the "Use Default Location" checkbox selected (meaning the project is created in the workspace directory). If you create a project and specify a custom location outside the workspace, renaming that project in Eclipse does not rename the project's host directory. In that case, you'll probably want to:
Rename the project in Eclipse (which will update any internal references and the .project file)
Remove the project from your Eclipse Workbench view (making sure that the "Delete file contents" option is NOT selected in the delete confirmation dialog).
Rename the project's directory in your filesystem.
Import the project back into your Eclipse workspace.
I was surprised to learn this (I tested it with Eclipse 3.7), but it seems to be logical to me. The idea is that projects in the workspace folder are considered to be "under Eclipse control" as opposed to projects that are located in arbitrary places on your filesystem.
Use Refactor to rename the project name. It will rename the file/folder in filesystem as well.
Menu -> Refactor -> Move... (Shift + Alt + V).
In this window you can change name of the folder name and also change the path completely.
If the folder name is important, then change it manually. Keep in mind that you will have to re-open or re-import the the project into eclipse. After you rename the folder, Eclipse won't know where to find it.
In Eclipse Oxygen (4.7) the Move option is greyed and renaming the project does not rename the directory. However, if you switch to the Navigator view (may need to find it under Window > Show View > Navigator) the Move option will be available and it will rename the project's directory.
This is a lot faster than having to recreate the project or re-import it.
If your project is a Maven project to rename, do steps as followed:
Open Context Menu on your project > Refactor > Rename Maven Artifact.
Change Group or ID.
Check "Rename Eclipse project in Workspace".
press OK button.
Update maven project by Context Menu > Maven > Update Project.
Using eclipse Neon 4.6.3, renaming does not work. You will have to do what E-Ritz said in his answer.
It is also worth mentioning that if you are importing a project as a Maven project (via Import... -> Existing Maven Projects), the project name will be taken from the pom.xml rather than the folder. So you should also change the <name>my-project-name</name> part of the pom