Using Workspace for different projects - java

My new job requires to work with eclipse and the IDE works well so far. But there's one thing I couldn't manage / understand. I am used to Visual Studio and there's a solution file containing some projects and the IDE enables me to work with them.
In eclipse I have my workspace and can add my projects. My projects may have some dependencies to each other and so on. Works great. But how to manage more than one projects ( or in the VS term solution)?
Do I have to use different workspaces? Ok, I can do that, but what if there's one project I want to use in two or more projects.
It's a beginner question, but an important one I think. So it should be interesting for other .NET users as well. Thanks a lot for helping.
Björn

In eclipse you can add as many as projects you need based on your project dependencies.So now wen we are talking about the dependencies whether do you want add the .jar file or project.Both the ways will help you to get rid of compile errors in your project.
1.Add muiltiple projects just by importing your project
File -> Import -> Select type of your project (Suggested options or i
use : Existing projects into workspace ,Existing maven projects)
2.You can link different projects by
Right click the project in eclipse -> BuildPath ->Configure Build Path
-> Projects -> Add --> (locate your projects in the workspace).
3.You can package your existing project as .war or .jar and add them into your project by
Right click the project in eclipse -> BuildPath ->Configure Build Path
-> Select libraries --> Add external jars (Then locate your jar's and add them).
Basically 2nd option is used in the debugging purpose,while the 3rd is bit tough to debug.
All these projects can be navigated using Project explorer window.

Related

Checking out SVN gradle project directly into eclipse?

Let's say I have a few java projects on an SVN repository. If I want to check them out in an eclipse workspace at the moment, I first need to check out the projects in the workspace, then import them as gradle projects using Eclipse Buildship.
If I try to check them out using the new project wizard, it seems to just initialize another gradle project on top of what's already there, leaving me without the files I was trying to check out in the first place. What I would like is to be able to directly check these out as gradle projects, in a one-step process as opposed to checking them out and then re-importing them into my workspace. Is this possible? If so, what plug-ins or gradle build configurations are necessary to achieve it?
Right-click on your project at Project Explorer -> Configure -> Add Gradle Nature should change your project's configuration to a Gradle project without creating any configuration file.

adding jar file dependencies

I have a Maven project that I've taken over and imported to Spring Tool Suite.
I added the Java facet so I could use "Open Declaration" and "References" to find out info about various classes used in the code.
The problem is, now I've got all kinds of errors because jar files (managed in the pom files) aren't on the Java build path. I've got them all in my .m2 directory but really don't want to add them by hand (there are about 100 or more buried in a deep directory structure)
Do I have any options to detect automatically or something that will prevent me from adding them 1 by 1?
Try this:
Select your project in STS (Sprint Tool Suite)/ Eclipse
-> (Right-Click)
-> Maven
-> Update Project (shortcut Alt+F5)
-> (Check all, except 'Offline' option) and press Ok
It will rebuild your project and hope solve your problem.

imported maven project does not appear as java project. Shows folders

I checked out the existing project source code from SVN to a folder in my system.
Then I opened eclipse. Import Project-> Existing Maven Project.
It imported without issues. However, Project Explorer shows it as just folders instead of packages. (Like when we create a package and then add classes to it, it shows a different icon for package root). I opened Navigator and Package Explorer as well. But they are showing them as folders as well.
I tried:
mvn eclipse:clean
mvn eclipse:eclipse
on the root of the project. But it did not help.
Can anyone help on this one?
My folder structure:
ecs->
ecs-ejb->
src/java/main/com/xxx
pom.xml
ecs->ear->
src/java/main/com/xxx
pom.xml
pom.xml
Try to:
Right click the project->Configure->Convert to Maven Project
---- Edit ----
If this doesnt work, it is likely that someone checked in their environment files into your SVN. If they checked in:
.project
.classpath
.settings/
They could be conflicting with your environment (different settings/plugins/versions of eclipse...). Try dropping your project, deleting the folder/files, then remove these files from SVN, and repeat your initial process. All of these files/folders will get generated during the import to eclipse.
---- Edit 2 ----
Per your recent edit to the question, you have a multi-module project. If you only did this on the parent project, then there is no source folder. So you wouldn't see it. You should:
File->Import...
Choose Existing Maven Projects, Next
Set the Root Directory to ecs/ecs-ejb, Finish
Repeat for all other modules.
In eclipse, each module of a multi-module maven project needs its own eclipse project.
Right click the project->Configure->Convert to Faceted Form
This solution worked for me
Possibility is Module doesn't have .classpath.
Kindly right click on Module and Change Project fact as Java.
else
If you are using command Prompt.
1. mvn eclipse:clean
2. mvn eclipse:eclipse
else
Delete Project from Eclipse don't delete content from disk. remove .classpath and .project
Re-import as maven existing Project
Right Click->Maven->Update Project.
Above works perfectly fine for Eclipse Juno and solves the problem.
You just need to change the nature of the project.
For MAC->
-> Right click on project
-> Properties -> Check Project Natures
-> Then add or remove accordingly if you are having a maven project then add Maven, add Java
I had the same problem. I tried a lot of things that I read on internet but the only way that I found to solve my problem was exclude all of my workspace files (.metadata folder) and create another one.
After that, I imported a existing maven project and all my problems are gone.
I also faced a similar issue. I resolved it by downloading the correct apache maven plugins in the maven repository org / apache/ Maven/ plugins. IN my case, everything was working fine earlier and I had deleted .m2 repository completely. After that I started getting these issues with same iDE and newer IDE versions as well. The pom.xml showed error related to lifecycle mappings. On downloading the correct plugin, the workspace worked fine.
Delete the metadata folder. Checkout again but select "Checkout as a project configured using the New Project Wizard" instead of "Checkout as a project in the workspace".
Then a New Project wizard will open, type maven there and select "Checkout Maven Projects from SCM" preferably or "Maven Project". It should work. Remember this step should be performed for Maven Projects only. For normal Projects just select Java Project or whatever relevant type Eclipse project it is.
Check and make sure you have eclipse pointing at a Java JDK directory instead of a Java JRE directory.
I had just installed eclipse and only the JRE was in the settings. I added the JDK path, changed it to the default and clicked on Maven -> Update project. Then the packages appeared in Package Explorer.
The hint that helped me figure this out is that when I tried to use the refactor to rename a class, it wouldn't do it, complaining that it wasn't a JDK.
Instead of importing as Existing Maven Project, follow below steps
I assume that your folder has pom.xml, src/main and src/test.
Step 1: Right click > Create New > Java Project > Chose the project folder has pom.xml
Step 2: Right Click on Project > Configure > Convert to Maven project
I got it working using Proyect --> Properties --> Project Facets
In my case was a web project so I checked Java and Dynamic Web Module
Try right click on project, Maven->Update Project... (or similar, the link name changes depending on version)
This works for me when adding new folders, but I have not encountered the problem when importing a project.
Right click the project, then click Configure -> Convert to Maven Project. If the packages still display as ordinary folders, then right click on the folder one level up (the one that is supposed to be the source folder), then click Build Path -> Use as a source folder.
Here is my solution please close the Project Explorer at the left top and open again.
(or)
1). Right Click on your miscellaneous project and choose project Explorer if available.
Adding projects to working sets should help
try it ->
right click the project -> Maven -> Assign Working Sets... -> Add projects to working sets

Add scala capabilities into an existing EJB eclipse project

I have an existing EJB project set up in Eclipse Helios, and would like to slowly introduce Scala into the project. The Scala IDE has been installed successfully, and I'm able to create standalone scala project. The issue however comes when trying to use my existing project with scala additions. I've went as far as manually editing the .project, .classpath, and related files under .settings of the project's home directory for eclipse.
However I still have the issue where the Java compiler tries to compiles .scala classes, which results in errors and ultimately not being able to build the project.
Has anyone faced a similar scenario or are there any workarounds?
Thanks in advance.
You should be able to right-click the project, go to "Scala" and click on "add scala nature". Then .scala files should be recognized as such. You might also have to add the scala library to your dependencies. Depending on whether this is a "simple" Eclipse project or you're using Maven there might be other steps required.
Right click on project, and choose Configure/Add Scala Nature.

Adding custom maven project as dependency

I'm using eclipse with the m2eclipse plugin now I just want to resolve a - imho - easy problem: I've got two maven projects, I want to add project A as dependency to project B.
Well how do I achieve this in a manner way? If I add the project A to the build path of project B eclipse recognizes the classes but this project isn't resolved by eclipse on build time.
I got it working by installing project A to my local repo and adding this as dependency to my pom. This works but is cumbersome because I always have to install a new version of project A when something changed.
Shouldn't the plugin handle such a situation for me?
Providing that you have both maven projects open in your workbench then make sure you have the "Enable Workspace Resolution" option enabled in the Maven context menu.
Yes Eclipse handle this situations.
You can add both the Projects A and B in the same work-space.
I could help you creating a simple work-space from the scratch.
I am assuming that you have already installed the MAVEN plugin M2Eclipse for Eclipse.
Start a new Eclipse in a blank Work-space
Right click on Project Explorer --> Go to Import dialog and add a Maven Module.
Locate the POM directory and add that directory.
It will list all the projects in all the sub folders.
Add as many as Maven Based modules in a single work-space.
By doing this you dont need to install the dependencies. Any change will be reflected on the derived module.
Hope that will help you.
The way you did it is correct, because it assumes that project B will be using the dependency of project A that will be in the artifactory, so you can develop both independently.
And anyway, for the project A, if you are using maven, don't you use maven clean install for compiling and deploying? That way you are sure you always have the latest version
The other option is, in case both of the are more dependent of each other, you should consider make one of them as a module of the other, or maybe make a project C that contains both modules, but that would mean both of them are part of the same project (like an ear containing two jars), depends on the situation

Categories

Resources