Import different versions of a project into Eclipse - java

I have a project in Eclipse and now I want to import another project with a different name and in different location, but with a same structure(same packages, a lot of same classes...), but when I try to import it, it says " Some projects cannot be imported because they already exist in the workspace". What should I do if I want to have both of two versions of one project? What should I change? Thx.

As the projects would have the same project names in the .project file, eclipse would not allow them to be imported into the workspace.
Open the .project file for the project root, confirm and change its name and then import it.
<projectDescription>
<name>project1</name>
</projectDescription>

What you can do is create a new project with the name that you want it to be called. Once you do that right click on the new project and click import. You can then import your old project into this one which will have all the same files except a different name.

If the project has a different name that message is a bit strange. Anyway try editing the .project file in the root folder of the second project and change the value of the tag name
The .project file is hidden

Related

The import org.xxx cannot be resolved

I'm new to Java, so bear with me...
I have placed a jfreechart-1.5.0.jar file in a lib folder and wanted to do do some imports like this:
import org.jfree.chart.ChartFactory;
But VS Code is complaining: the import org.jfree cannot be resolved.
One thing I have to mention is, that I have created a copy of the project folder in order to try something. Because it worked, I have deleted the original folder and renamed the copy to the name of the original folder.
But now I have the problem that the imports do not work anymore, even it's the same code. I have "cleaned Java language server workspace" but it didn't help.
Is there anything else I have to do? Is the jar import pointing to a certain path / file?
For Maven project, you can add a dependency by clicking the + icon next to Maven Dependencies node in project view.
If your project is an unmanaged folder without any build tools. You can manage the dependencies by clicking the + icon or the - icon on the Referenced Libraries node or the items under it.
I had to reference the jar file to the project.
Surprisingly the first time it has been referenced automatically, the second time I had to do it manually...

How to import source files in Java to use in another project

I have been writing a project in Java that I've called NHL2 and at this point in the development I've decided to try to incorporate wheels which can be found here. I've downloaded and unzipped the folder, and tried to import the files in several different ways. In Eclipse I've tried right-clicking the NHL2 project and importing it. The files get inserted into certain places in the project but when I type import wheels.etc.* for instance, it gives me an error and says it cannot resolve the import. So I tried deleting the imported files, right-clicking the package containing my files, which is also NHL2, and running the import command through there. Again, same basic problem.
I've also tried just creating a whole separate project titled wheels and importing there. This seems to be fine and the wheels project itself has no errors, but still I cannot import those files in my NHL2 project. I've tried looking up YouTube videos and other stackoverflow questions because this seems like it's just so basic that it should have been answered by now, but I can't find it.
Create a new Folder in your Project, e.g. called "lib"
Copy the wheels.zip into that Folder
Open the properties of your Project (Alt-Enter on the Project)
Select "Java Build Path"
Select the Register Card "Libraries"
Click "Add JARs"
Select "Yourproject/lib/wheels.zip"
Click "OK" then again "OK"
Though it is no jar file (but a zip) it works. I tested it.
This is because the zip contains the class files and the source files as well.

My projects are not appearing in eclipse

I face strange problem, Yesterday I was checking my projects and also I created a new project to the work-set.
Today when I opened eclipse and loaded my work-set I found that my projects are not loaded into eclipse. I checked the work-set folder I found that all my files exist in the work-set folder but those projects are not visible nor loaded into eclipse as if they are not exist.
I have also more than one workset,the one that does not appear in eclipse named workset00. workset00 folder exist one the hard drive but does not appear in eclipse. Unlike others worksets such as workset01 or workset02 they
I hope the I explained my problem clearly.thanks.
check out your workspace path is set properly to the workspace ur expecting to set or it different.. please check care fully directory by directory. if everything is proper still wont work, then do the following
copy all projects some other temporary folder and delete that directory.
create new workspace in eclpise.
just copy paste all ur project to the new workspace directory.
use import project from ecplise.
and your set
Try reimporting them or import them in a new workspace.

No Package Hierarchy Importing Project in Eclipse

I've been trying to import a project that works on a friend's computer, however no matter what I try, the package hierarchy is completely lost and the result is this
Has anyone seen this issue before? I've been struggling with it for a while. Occasionally creating a new project and copying in the src folder works, but I've been unsuccesfful in my recent attempts.
The presentation of packages is a user option. Click the little down-arrow at the top of the package panel, then select "Package Presentation" from flat to hierarchical.
Turns out we weren't including the .classpath file in the source control. Facepalm. Good answers, though.
It could also be that the folders are not listed in the project as Source Folders. Go to the project properties and check that the root folders (looks like "data" and "src" here) are listed as source folders in the Build Path.

Eclipse WTP: "The import ___ cannot be resolved for" error in a JSP file for a class defined in project

A Visual Studio user struggling w/ Eclipse...
I imported a set of servlets/JSPs into a project in Oracle Workshop for Weblogic. /page.jsp has the following import statement:
import="com.foo.bar.*"
Eclipse is displaying an error:
The import com cannot be resolved.
The class that implements the above import is in /WEB-INF/src but I don't know how to build the class in Eclipse to resolve that error. I assumed Eclipse would automagically build the .java file and place the output in /WEB-INF/classes, but it's not doing that.
It could be that I haven't structured my project directories correctly so perhaps that's why Eclipse isn't building my source. Any suggestions? How can I get this to work?
First of all, /WEB-INF/src is a rather strange place to keep your java sources; you may want to move them out of /WEB-INF (into /src in project root, for example)
Either way, you need to tell Eclipse where your sources are and where you want classes built to. It's done in project properties dialog:
Right-click on your project in Eclipse, select Properties
Click on Java Build path on the left
Click source tab on the right
Click Add Folder button and add your source folder (/WEB-INF/src or wherever you moved it to)
Ensure Allow output folders for source folders is checked below
Under newly added source path select output folder and point it to /WEB-INF/classes or other location of your choice.

Categories