File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes IDEs, Version Control and other tools and the fly likes creating a new project in eclipse from an existing web project Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "creating a new project in eclipse from an existing web project" Watch "creating a new project in eclipse from an existing web project" New topic

creating a new project in eclipse from an existing web project

sean divine

Joined: Oct 27, 2005
Posts: 14
I'm totally new to eclipse and am trying to become familiar with how to implement eclipse's workspace/project approach with an existing site. (Formerly, I used JPad Pro but since I lost my version with an old machine, I decided now was a good time to make the switch.)

So I presume (and hope) that this is a very simple question but so far I've failed to locate an answer.

I wish to edit, compile and create new java files for a website that is already live. I use dreamweaver to both edit the html in the site and upload files to the remote server.

I understand that I can import existing packages into the eclipse workspace by simply moving them into a newly created project folder in the workspace.

But this is not desireable to me because I want to maintain an exact replica on my local machine of what resides on the remote web serving host. The project in question currently resides within a folder on my hard drive that contains a directory tree identical to that on the live remote server that hosts the website. Also, the site is defined in dreamweaver as existing at this specific location on my hard drive.

If I were to move the package files into a new project folder in the eclipse workspace, I would lose the integrity of my mirror copy and the ability to upload the files to the remote server thru dreamweaver.

Another option I considered was to define the eclipse workspace location as the WEB-INF folder in my local site. Then would I name the project "classes" since that is where the servlets and packages reside? This would not be a very descriptive project name.

Again, I suspect this is a simple problem yet I'm scratching my head nonetheless. How is this usually done?

Thanks for any insight into this.
Sunny Kumar
Ranch Hand

Joined: Oct 27, 2005
Posts: 57
Right click on your project name and select Import.
From the list displayed select the option File System.
Browse your project directory and import the files you want.
Hope this helps.
sean divine

Joined: Oct 27, 2005
Posts: 14
Thanks a ton for your reply. That is an interesting method. And I like the way you can choose which files to import (without having to import all of the images, etc. that you will not be manipulating in eclipse.)

However, the files that get imported are physically copied into the workspace. This seems like an inefficient use of hard drive space since the same files then exist in two locations. (Although, this is not really such a big deal since you are able to reject importing unecessary files like images and because memory is so cheap and plentiful these days.)

But a more significant problem with this method you suggested is that the copies that are created in the workspace are not linked to the originals. So editing the files in eclipse will not change the files in the original location where they are uploaded to the server. So this method is tantamount to simply copying certain files and folders into the workspace. I would then need to copy edited files back into their orignal location, overwriting the earlier versions, in order to upload to the server. This seems unecessarily inefficient.

In my research, I found several different methods of importing or linking. Some phiscally copy the files to the worksace while others do not. I found one method that phiscally copied the files while keeping them linked, so that editing a file in the workspace caused the original file in the original location to change also. I can't recall how I did this at the moment but I remember being pleasantly surprised that two files were simultaneously updated when either one was edited and saved.

I also found two methods that imported files or file structures into an eclipse project without actually creating new files in the workspace. This seems most sensible because no unnecessary duplicate files are created on the hard drive. But one of these methods (right click a newly created package and then choose new->folder->advanced->link to folder in the file system) didn't do the trick so well because it requres naming the new file and then expects every package in the project to be a child of this new file name, i.e. newFileName.WEB-INF.classes.myBeans.

The best method I have found so far turns out be be pretty simple: file->New->Project->Java Project. Then in the dialog, click next and after naming the project, under "Conetnts" select "Create project from existing source" and browse to the top level folder of the site (where indes.html resides). This seems to do the trick.

Thanks again for your reply.
Sunny Kumar
Ranch Hand

Joined: Oct 27, 2005
Posts: 57
I already had the idea of creating a project fom existing workspace but didn't knew that it was going to keep the files copies identical.
Nice research sean.
Thanks for letting it know.
subject: creating a new project in eclipse from an existing web project
Similar Threads
Eclipse projects on removable media
157 Question Help and Resourses
What is an eclipse "workspace"
Deploying from WSSD
ibm websphere test 157 for websphere studio application developer 4.0.3 for windows