Import existing src into root directory of Eclipse Project? - eclipse

I am using Eclipse Indigo. I already have some code that is stored in a repository outside of my workplace directory. The repository contains various projects and so it wouldn't make sense to include it in the workspace. I have created an empty Java ME project and I now want to import various source files and folders by linking them in. I've played around with various settings, but Eclipse insists on creating a top level folder to hold them. To be clear, the hierarchy is:
Java ME Project -> Unwanted Top Level Folder -> Source Files and Folders
Can I make it instead:
Java ME Project -> Source Files and Folders
Update: Thanks Srikanth for the doc link. According to it, the file system should have a "Create selected folders only" option, but it isn't showing in my version (3.7.0.v20110530)

This feature does not seem to be available in Eclipse 3.7. In 3.6 (and maybe lower) it is possible though. While importing the existing src select Create selected folders only radio button.It will import only the wanted folders.

Related

I need Netbeans help. NO project's -src node appears so no source files--only -Libraries node shows

I hope it's OK to ask this here. Netbeans forums isn't responding. If not, I'll delete this or ask for it to be deleted. I'm desperate so I'll face the wrath, if any.
I moved my Netbeans projects folder from one directory node to another to make backing up all my stuff easier. BAD MOVE.
Now when I open a project using Files | Open project (ctrl-shift-O) NO source files appear because there is no "+Source Packages" node to expand.
It looks like this for all projects, e.g. one named GBL:
Projects
-GBL
+Libraries
It doesn't look like this anymore:
Projects
-GBL
+Source Packages (How do I get this back?)
+Libraries
The Netbeans Properties for each project shows me the path it's using. Windows 7 Explorer shows me that the src, build, and nbproject folders contain files and ALL the source files are in the src folder for that path.
What have I done and more importantly what should I do to get back to being able to open a project normally?
(I've tried recreating the original Netbeans folder and using Windows Explorer to copy an entire project folder into it but: same result--all I see is the Libraries node under the project's name node.)
I just tried to Clean (and also Build) to see what would happen. Error:
ant -f C:\\Users\\Dov\\Documents\\NetBeansProjects\\BasicShirt -Dnb.internal.action.name=build jar
C:\Users\Dov\Documents\NetBeansProjects\BasicShirt\nbproject\build-impl.xml:[u]231[/u]:
Must set src.dir
I just Set Configuration by right-clicking the project's name and provided a path to the src folder.
NOW I SEE MY SOURCE FILES BUT NOW THIS line in the .xml file is flagged with similar message:
<fail unless="[u][b]test[/b][/u].src.dir">Must set test.src.dir</fail>
NOW what do I do? (Netbeans 7.4.)
If I could get rid of the 7.4 automatic creation of +Test Packages, I might be OK.
If you can help, I'd be very happy.
(I'm considering re-installing 7.3 if available or removing and reinstalling 7.4 and try to avoid the "testing" requirement, but there goes all my many tweaks of 7.4.)
Well, after considerable frustration with the problem, I solved it, essentially.
It's here, in total. My synopsis plus how it helped me follows. In short, I had to set up a new java project based on existing sources using the New Project Wiz and simply direct Netbeans to the sources.
File > New Project
Choose Java Project with Existing Sources.
Type a (new) project name and ...
... make the Project Folder contains the path to where you want the new project to be stored. (For me, this is the folder where Netbeans has been able to find my sources.)
Click Next for the Existing Sources page of the wizard and ...
5a. ... in the Source Packages Folder pane, click Add Folder and ...
5b. ... navigate to your sources and select the source root folder.
Clicking Next goes to the Includes/Excludes pane, which I didn't need to use.

Eclipse projects not showing up after placing project files in workspace/projects

I've searched for 2 days and can't find anything. I find things that are close, but not what I need.
I got a new computer recently and copied all of my projects over to my new computer.
I opened Eclipse and generated a workspace, which I then closed out of Eclipse and copied my projects into the workspace/projects folder.
I reopen Eclipse and my projects do not show up at all in the package explorer.
I know that I have the correct folders in the correct directory.
The closest thread I found to this is: Eclipse - Import an existing project?
but even that didn't help, my projects already meet that...
I have tried refreshing, reopening, fooling with working sets, etc...
Just because you have a project inside the workspace directory doesn't mean Eclipse opens it or even sees it automatically. You must use File - Import - General - Import existing project into workspace to have your project in Eclipse.
For Juno: (With Source in E:\workspace and destination in C:\workspace)
Copy project directory in its entirety to the workspace directory.
(e.g. Copy E:\workspace\HelloWorld C:\workspace\helloWorld)
Start Eclipse.
Perform: File --> Import
Select: General -- > "Existing Project into Workspace"
"Next >"
Check "Select root Directory"
Select with "Browse Button"
Select "C:\workspace"
A list of existing projects will appear. Just check the ones that are in Bold (To Be Imported) then press the "Finish" button.
Review the Package Explorer and your copied projects should now be there.
This problems comes while .metadata of current workspace has been corrupted due to shut down Eclipse Unexpectedly. So if you face this problem just do the following steps:
Create a new workspace.
Import your existing projects to your new workspace.
you made it!
I had the same problem over and over again the solution that a have found works for now
Close Eclipse.
go to workspace.metadata.plugins
remove org.eclipse.core.resources
Start Eclipse
Do File->Import
General->Existing Projects into Workspace and import all the project from the workspace
Netbeans allows you to do a simple filecopy.
As you know, Eclipse doesn't work like that. You must explicitly "import" files and projects.
If you do import, and if there are no problems, then they should show up.
I'd consider:
a) making a backup of your existing workspace
b) deleting and reinstalling Eclipse
c) Trying another "test import"
You put them in the workspace/projects folder. You should put them directly in the workspace folder and then do an Import Existing Projects into workspace.
in Eclips the Package Explorer
Right click on any viewable project and select Show in -> Project Explorer
Package Explorer -> Right click -> Show in ->Project Explorer
you should be able to see all the imported projects in your Eclipse workspace
Even I had also observed the similar problem. I had closed my eclipse project because of some reason and on restart some of my file added were not visible in explorer even though corresponding file were existing.
Following solution worked for me:
Select whole workspace (Ctrl+A) ==> Righ click and press Refresh.
Or you could try:
Go to File -> Switch Workspace
Select your workspace (if shown)
As I had imported my project from a "git clone", I had to select File->Import-> Git->Project from git -> Existing local repository
Here's a specific problem I ran into when downloading a project from the internet.
Make sure you unzip correctly if it's zipped, you can sometimes get an extra level.
Make sure you place the project in the project file, not directly in workspace.
See if .project and .classpath have been renamed to _project and _classpath. You can't rename them directly so open a text document called .classpath and paste _classpath 's contents in there, saving as all files, not a .txt. _classpath can be opened with notepad.
Import the project from the file workspace. It will look for a folder called projects, your's should be inside it.
Hope this helps :)
The following worked for me.
Create a new project in eclipse.
After creating a new project in
eclipse, right click and select import.
General Import > File System
Select all the folders under your project except the root one. Click
finish.
This would create the required meta data and other internal eclipse project file system which will display your project's files.
You can also import the project directly as a file system. Follow the above steps if you are unable to import it directly.
Hi i also come across same problem, i try many options ,but finally the most easy way is,click of down arrow present inside ProjectExplorer-> customize View->filter-> unchecked close project.
And will able to see all closed projects.
I have tried many of the option suggested but at last importing project in new workspace solved my problem.
I think there is some problem in metadata files in old workspace.
I just wish to add one important detail to the answers above. And it is that even if you import the projects from your chosen root directory they may not appear in bold so you won't be able to select them. The reason for this may be that the metadata of the projects is corrupted. If you do encounter this problem then the easiest and quickest way to fix it is to rid yourself of the workspace-folder and create a new one and copy+paste your projects (do it before you erase the old workspace) folders to this new workspace. Then, in your new worskapce, import the projects as the previous posts have explained.
Yeah.... i kinda see what you need. I just came across same problem.
Here is exactly what i did. Now, bear in mind, this some low level knowledge, since i'm just starting. I made my life complicated, so i needed solution. I kinda found it on my own, using different directions from above answers.
I switched from win 10 on HDD to linux on SSD, so i needed my few of .class and .java imported into new workspace.
First i made a mistake, not using export option on windows and i just simply copied all of files from src and bin folders on win 10 to src and bin folders on linux. Of course workspace did not see those files.
Solution was found in IMPORT tool (which i should have used right away).
I put all of files in src folder into zipp file, and moved this file to some arbitrary folder (Home folder in my case).
Go back to src folder and delete all of .java files (you won't be needing them anymore).
Then i opened my empty project and selected import from File menu in Eclipse.
In import window, under option General (first one) select Import Archive.
Now simply find your zip file, and Voila! All is where it should be.
Problem: After creating a PyDev Project, the project does not show up in "PyDev Package Explorer" ;(
Solution: This is what I do to see them all in "Project Explorer":
I am using Eclipse IDE 2019-12
click on "Resource" icon at the top right corner
Now you shall see all projects show up in "Project Explorer".
Tricky note: now if you click on "PyDev" icon, you will see less projects show up in "PyDev Package Explorer" Magic?
What I did wrong about it, I used "import" - > "Projects from Folder or Archive" because I thought it would be the same thing. You have to use "Existing Projects into Workspace". Maybe this helps someone.
I experienced the same issues and I just click on Window -> Show view -> then Project explorer.
Then I got my project that was inside my eclipse workspace.

How To Manually Add Project To Eclipse Without Using Eclipse

I'd like to manually create the folders/files on the file system that create a new project in a workspace in eclipse, and show up in the Project Explorer when eclipse is started and the workspace is selected.
What files would need to be created to do this and where would they need to be?
Please understand that I do not want to open eclipse and make a new project using eclipse. I want to make a new project without using eclipse.
I think you will need to do the following
create a .project file and whatever other files needed by your specific type of project (for example java projects need .classpath) in the project folder, you can find out what you need by looking at those files for another project.
In your workspace .metadata folder, this is where eclipse keeps information about the current workspace, I think the plugin responsible for project definition is .metadata/.plugins/org.eclipse.core.resources , you will need to create those files yourself, some of them are binary, so you will need to open up the source of that plugin to see exactly how it writes them. Depending on your project, you will need to write more .metadata plugin information (for maven for example).
There is no easy way of doing this. Each new project modifies many scattered files throughout the eclipse structure (if you want a list, make a new project and find files created/modified most recently, and/or search for the project name.)
Short of writing the files by hand, there's not much you can do. I found these links in my reseach, but they're both pretty old and seem to be dead ends:
http://www.eclipsezone.com/eclipse/forums/t107019.html
http://dev.eclipse.org/newslists/news.eclipse.tools/msg36546.html
Based on the answers of #shipmaster I think this will work.
Go the workspace and create a new folder as your new required project name.
Copy the contents like .project, .classpath, .includepath etc from any existing project and modify the same like project name, source folder, build folder etc in .project. Do the similar changes in .classpath etc as per the new project requirements.
Unfortunately this is not enough to create a project by just doing eclipse restart so we need to do an import project and point it to this folder and we are ready to use the same now and we see the new project created in eclipse!
try archiving the file .. right click on project ---> export --->archive file(in General section) ..after you archive it as a zip you can import it after.
IF you want to manually copy a pre-existing project to a new workspace,
I have a solution for you:
Copy the project folder.
Paste it into the new work space.
File > Import > General > Existing Project Into Workspace
Eclipse will now see the project you cut+pasted manually.
Why I am doing this:
I am doing this so I can build upon my scrum stories while keeping documentation via working files that each successive step was built upon.
E.g. Story #2 is built upon story#1 code. But I don't want to version them because I want to be able to open them up one after another to do a presentation on my work flow.

When working with Eclipse, should I add the workspace to the source control?

I am the only developer on this project.
I would not add the complete workspace, but I would add the .classpath and .project files (as well as the source, of course) so that you can recreate the project if needbe.
I wouldn't commit the whole workspace. But it is worth exporting platform settings and checking them into source control (probably in a separate SCM project as they don't really belong to any individual project) if you've made several changes in case you need to import them into a new workspace.
Examples of these files are those settings for:
Java->Code Style->Formatter
Java->Code Style->Clean Up
Java->Code Style->Code Templates
General->Editors-Text Editors-Spelling-Dictionary
Any other preferences you've made extensive changes to that support import/export
You should check in the primary sources/resources for the project. As others have noted, for a typical project this includes the .project and .classpath files.
Depending on the type of project, I'd add the .settings folder from the project. This folder contains project-specific settings that override the platform preferences, and other project-specific settings. If those are essential to your project then I would add them.
No.
Files that are generated by the IDE or by a build process (binary files, documentation produced by a generator) should not be checked into source control. The only files that should be checked in are your source files and external libraries that your source files utilize.
You might also be interested in the answers to this question: What should NOT be under source control?
I would commit only the project(s) you are working on, as well as .classpath and .project files, and not the whole workspace itself.
Even if you are the only developer, avoid committing the .settings directory. You could switch to another version of Eclipse, or another installation with a different set of plugins, and when you checkout projects in the second installation the .settings directory will be different. Also the .metadata directory is bound to vary.
That said, attempt to use Maven so that the Eclipse .project and .classpath files can be generated without requiring them to be checked in.
I've played with the idea (with Subversion) of having a "MyProject_Eclipseproj" folder that only contains the the Eclipse project files and directories, with an svn:externals prop that pulls in all the "MyProject" files/directories.
So, the layout would be:
/repos/trunk/MyProject
/repos/trunk/MyProject/build.xml
/repos/trunk/MyProject/src
/repos/trunk/MyProject/src/com
/repos/trunk/MyProject/src/com/mypackage
/repos/trunk/MyProject/src/com/mypackage/MyClass.java
/repos/trunk/MyProject_Eclipse_34 <- external prop goes here
/repos/trunk/MyProject_Eclipse_34/.settings/
/repos/trunk/MyProject_Eclipse_34/.project
/repos/trunk/MyProject_Eclipse_34/.classpath
/repos/trunk/MyProject_Eclipse_35 <- external prop goes here
/repos/trunk/MyProject_Eclipse_35/.settings/
/repos/trunk/MyProject_Eclipse_35/.project
/repos/trunk/MyProject_Eclipse_35/.classpath
The MyProject folder would be pure code, no eclipse contaimination. The MyProject_Eclipse_Ver would contain Eclipse specific files, and pointers to pull in the code folders. You could also have specific folders for different Eclipse versions so each developer wouldn't be forced to upgrade if something changed in the .settings or .project file between versions.

In Eclipse, how can I move all my source files to a different folder without screwing up the project?

I have created my ActionScript source files in a folder on a Mac (I normally use Windows), and somehow managed to make an Eclipse/FDT project that can see them.
I now need to move them into a svn checkout of an existing project to get them under source control.
I just can't work out how you do this without losing all references in the project.
I'm new to Eclipse and don't really understand any of the terminology (e.g. workspace). Does Eclipse have project files or are they all hidden? Can the project file be moved?
Help me stackoverflow, you're my only hope.
Update:
From the FDT Flash Explorer window I can only seem to be able to move files/folders within projects that exist. Should I create a new project in the place I want first?
Should I move them from within Eclipse or from the file system? Do I need to setup a new workspace afterwards?
The project folder has 2 hidden files: .project and .classpath that have all the info of the project. You just need to copy those files along with your project files.
For instance, you have a project folder in workspace/myproject/, and you want to add it to a checkout svn folder, you just need to copy the complete folder content to the checkout and then add all the files to the svn (including the project hidden ones) and finally commit.
From now on, when you checkout from that svn, you will have the eclipse project files, so all you need to do is create new project, and select the option that says that you already have a project folder with the source files (I'm not near an eclipse IDE to tell exactly the steps, but it's something like this). Eclipse will then import the project with all the settings you had previously defined.
I hope that this answers your question.
Try refactoring your project. Rightclick on the folder to move and then choose Refactor->Move. Don't know if this will solve your problem but it will try to change the references in all projects according to the move.