Should renaming a project in Eclipse also rename project folder on file system? - 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

Related

Not finding libgdx projects to import them

I bought a new computer and installed Eclipse on it. After the ADT plugin finished downloading I tried to import my projects (composed of 4 sub-projects), but Eclipse doesn't see them!
I just click "import/general/import existing projects into workspace", select the folder containing the sub projects, hit the open button but Eclipse says "No projects found to import".
I'm using Eclipse Kepler and the projects files are directly taken from Eclipse Juno.
Eclipse need .project file to import the projects into workspace. what you can do is create a new project and copy the source and libraries into that project
Alternative method can be that create a new project and copy the .project file from that project to your project but make sure you edit the .project file and change the name of that project according to your project. read this for more information on .project file
http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fmisc%2Fproject_description_file.html
I will suggest you to use the First method .
Make sure that you've tried to:
Refresh everything
Searched for Nested Items
Go to (In the libg-gdx setup) Advanced >> Check Eclipse
And if that doesn't work, add a .project file into the folder manually

Eclipse - why cant it integrate jars in lib folder into project?

I manually copy needed jar files into my project lib folder. Then, I try to add them to build path via "configure build path option". If i choose "add jar", then the lib folder does not show up in the "to choose from" list. So, I am forced to use "add external jars" option instead. But, that option does not make the jars a part of the project even though they lie in the lib folder. After I restart eclipse 2-3 times, the jars are magically integrated into my project.
Why is eclipse behaving this way ? Why can't I do this easily ?
Please help me.
By default, Eclipse dose not detect file change which come from outside, like copy a jar file in lib folder manually.
So after you copied jar files, you have to refresh the project by pressing F5 while selecting your lib folder. I believe that's why eclipse cannot found your jar files.
If you want to solve this problem once for all, you can active "Refresh using native hooks or polling" via
Window -> Preference -> General -> Workspace
However, this might slow down Eclipse if you have a big project with many many files.
UPDATE
As Bananeweizen mentioned, instead of doing all the copied from outside of Eclipse, you can also copied those file into Eclipse, Package Explorer View for example. This way Eclipse will detect and refresh folder automatically.
The way I was taught to add external jars to an eclipse project is to drag the jar file from explorer into the lib folder in eclipse and then on the dialogue eclipse responds with is choose the copy to option and eclipse imports the jar file and copies it to the lib location at the same time.

How to open project from workspace in Eclipse?

I imported an Eclipse project into workspace and after some time I deleted it in Eclipse (from project explorer but not from workspace). Now, I want to reopen it, or import it again, but I cannot import it because such a project already exists in the workspace and when I try to open it, in tab Project -> Open Project, it is disabled. Of course, I can delete the project from workspace and import it again, but this is not what I want. So the question is: how can I open the project, which is in Eclipse's workspace, but has been deleted from the Eclipse's project explorer?
This is exactly what I just ran into. The 'Finish' button is greyed out, as is the check box and project name in the project window. If you try to check that check box the project will not be greyed now, but it won't check. Refresh does nothing.
The trick (or is it a bug) is to uncheck 'copy projects into workspace' hit the refresh button and it will now be checked and you can hit the finish button. Project will now once again be available in the Package Explorer.
(I'm using Eclipse 3.8 and ADT 21.0.1)
These Steps You Have to Follow
Click File menu
In file menu click Import
A window is open Now click General Folder
Now click Existing project into workspace
Then click the select from root directory
Now import project which you want......
You have to choose the project in the workspace, not the zip file with your project. Your project is still in your workspace, and because Eclipse wants to copy the project from the zip file you chose (look at the checked check box "Copy projects into workspace"), you get that warning.
Just select "Select root directory" and choose your workspace as your root directory and choose the project you want to reimport (and make sure, that the checkbox "Copy projects into workspace" is not checked).
Go to “%ECLIPSE_HOME%\configuration.settings” and delete the workspace listed at the key RECENT_WORKSPACES
Restart Eclipse, go to File>Switch Workspace>Other… and select your workspace dir again
Now I could create new projects as always
One simple trick is to delete the project from your work-space directory manually and than try to import project again. That's it...
I've experienced this same problem. It was a deleted workspace which I re-imported. When I tried to work with junit tests in the directory, it said that parts of if were not in the "project" In order to fix this, I had to check the "SEARCH FOR NESTED PROJECTS" and that corrected the issue.
I know that this is a really old question, possibly the solution was not available back then, but on my system (Eclipse Photon 4.8.0) it works like this:
File menu
Open Projects from File System...
Here you can give Eclipse a path to a directory (in this case your own, currently used workspace directory) where it will search for possible projects, list them and let you choose which one to import into the workspace. It will show already imported (aka. existing inside Eclipse) projects grayed out and unselectable, but has an option to hide these as well.
After selecting the project you'd like to import just click the Finish button and voila.
Make sure that your project is included in current workspace, then you have to see the project under "Project Explorer".
Note: you can view this from: Window->Show View->Project Explorer.
If you are facing this:
Some projects cannot be imported because they already exist in the workspace --> "Finish" button is grayed --> hence, no way to open the project(s)
Solution:
Go to File -> Open File...
Choose any one file of your project, and the entire project folder will open in your present workspace.

How to convert IntelliJ project to Eclipse?

I have one IntelliJ project and I want to open it in Eclipse, so what should I do?
There is an export to eclipse option in Intellij Under file menu.
This option will generate you the necessary .project and .classpath files that will be used by eclipse. Personally, I would remove any IDE dependencies using some dependency management systems like Maven or Apache IVY. ( Is system the right term?)
I had the same issue and (I don't have Intellij) but doc_180's comment pointed me in the right direction. Here is a simple solution. In Eclipse create a new blank Android project. Copy the .project and .classpath files and the .settings folder to the Intellij folder. Edit the .project file and change the name of the project.
You should now be able to Import the project in Eclipse by right clicking and selecting "Import->Existing Project into Workspace".
I see this is an old question, but thought I should add this answer for others Googling it like me ;)
Without access to IntelliJ to export and convert the project, try the following.
In STS or Eclipse create an empty project first, then, select File -> Import and choose General -> File System. In the resulting dialog box, select the root folder of the IntelliJ project as source and the empty project as the destination.
For unit tests, add the test folder as a source folder to the build path (right-click on the folder, select Build Path -> Use as Source Folder).
The projects I import this way run without any further modifications, including the tests.
Eclipse and Intellij create different project structure each other (Output path, Source Code etc...). You can export the current project to Eclipse environment.
File -> Export -> Project to Eclipse

eclipse workspace: how to rename workspace

There is no option in the file menu to rename a workspace. Is the recommended practice to close eclipse, rename the folder, and re-open? I worry about some potential dangling references in configuration files corrupting my workspace/projects...
Thanks!
Source : Renaming a workspace?
Yes, you can just rename the workspace
directory and/or move it. However, you
then have to tell Eclipse where the
new workspace is. In 3.1, you can use
'switch workspace' to launch in a
different location (under the File
menu).
If you want to change it by hand, you
can edit the appropriate entries in
the files in the 'configuration'
directory where Eclipse is stored.
You can change the
org.eclipse.ui.ide.prefs file to set
SHOW_WORKSPACE_SELECTION_DIALOG=true
if you want to be asked each time
Eclipse is run where the workspace is.
For simple renaming, it is not necessary to switch workspaces, unless the workspace you want to rename is not the one currently active.
Anyway, you can rename the current open workspace by choosing Eclipse->Preferences->General->Workspace and changing the option "Workspace name (shown in window title)" from the default's workspace folder name to whatever you want to call it. Then, restart Eclipse.
Suppose your workspace's folder is "/foo/bar/workspace" and you never changed its name before; its name was then the default "workspace". After you renamed it to, say, "my_workspace" and restarted Eclipse, the Eclipse's window title should show: "my_workspace - (some stuff that varies) - /foo/bar/workspace".
Note that this is NOT going to modify the workspace folder's name. You may have to create a new folder with the desired name, switch to that folder (whose workspace will have the same name, by default) and import existing projects into it, as some have suggested here.
Renaming Workspace folder worked for me. Close the eclipse, rename the workspace folder name, launch eclipse again. If you are using any project dependencies like user libraries,launchers etc, you have to relocate those to new location manually, from project build path.
Copying workspace to a new folder works. Any reference Eclipse itself needs is resolved using the relative workspace location. If you have added launchers, substitution variables, etc. that rely on the absolute workspace location, they will need to be reset.
John,
I think in the original workspace you imported projects and that the projects depend on links not on being physically in the same location of the worspace (even thay are there already but the dependency is on links). If so you have to remove the projects from the new (copied) worspace and then re-import them again.
I just did a:
File --> Import --> Maven --> Existing Maven Projects --> mention the new workspace location in "Root Directory" in the "Import Maven Projects" window
and it worked! All projects were imported properly.
BTW, I have Eclipse-Maven plugin "m2e" installed (http://wiki.eclipse.org/M2E_updatesite_and_gittags)
2021 Update
In Eclipse 2020-12 (Windows 10), the "Workspace name (shown in window title)" preference mentioned in one answer is no longer there. Now, renaming a workspace (WS) requires a copy and delete operation.
Start by switch to another WS: File --> Switch Workspace --> select existing WS. Then rename the WS folder to desired new name. Switch to the new workspace folder and delete the old name:
File --> Switch Workspace --> Other...
Right-click old WS name --> Remove from launcher selection
Click Browse --> select new workspace folder --> click Launch and Voila!
As mentioned in prior posts, depending on your setup some resource links may be broken. Delete the project without(!) removing it from disk, then import to new WS.