jar libraries not updated in eclipse with git - java

I am developing java projects in eclipse and version controlling with git.
What I found today was that the jars of user library was not being updated after pulling a project from git server to another repository/directory. The newly exported jars after adding new classes or functions were not recognized.
So I removed the user library with the problematic jars. The eclipse java project still has access to the jars.
Create a dir.
Git init
Create an empty java project
Pull from git server
The above is the steps that caused this problem. I didnt commit the empty project before pulling.
Thanks~

Have you tried refreshing the project? (Right click on your project and then select Refresh)
Your changes done to the file system (pulling stuff from git) are not known to to Eclipse, so you have to explicitly tell Eclipse that it has to refresh its idea of what are on the file system.

Related

Eclipse maven EAR project not working after git share

I have a working maven project on eclipse which I made using the archetype for Jakarta EE with an ear packaging using windfly 21. (org.windfly.archetype - wildfly-jakartaee-ear-archetype).
After i got a working webpage, i decided to share it on git, using the eclipse GUI. (Right click on project -> Team -> Share).
This moves the project onto another folder, as it says that having git repositories inside eclipse default workspace folder is not recommended.
The problem is that after sharing it, even before I commit or push, it stops working. It stops recognizing packages and I'm unable to make it "run on server".
This is an image of how it looks after I share it on git. I cannot execute "p1parte1" or "p1parte1-ear" anymore (neither any of the other projects/modules), and the other projects below dont have the java classes inside.
I literally have no idea how to fix this, i've spent like 3 hours searching online and trying things.
I solved this by manually fully copying the project that was not shared in the eclipse workspace folder to the git folder.

How do i manage workspace.xml in Intellij with git

I started a new project with my team. We are using Intellij + Java + git for developing the software.
The problem I have is that I made a .gitignore file for git auto-generated by gitignore.io. The file ignores the workspace.xml and the Project.iml files in my Project, which is good, because they cause merging conflicts later.
The thing is when I push the project on bitbucket.org and my collegues want to clone it so they can work on it, they have no workspace.xml. So Intellij can't open it up as a project.
Is there any way they can generate the missing Files or any Import option to make it a project again?
workspace.xml is not required for opening an IntelliJ IDEA project. On the other hand, the .iml file is a required part of the project and needs to be shared in the version control system if you want to share your project with colleagues.

Can I convert eclipse source folders into packages?

I've forked a Github project, used Eclipse to clone it locally, and imported that as a general project into Eclipse.
The accompanying .project file is an Eclipse .project file with the proper "nature" and "buildCommand" xml tags.
So it seems like a valid Eclipse project. However, I'm unable to specify a run configuration or configure the build path.
When I select the Build Path popup menu item, it says "no actions available" in grayed out text. When I select "Run/Run As" from the main menu,
it shows (none applicable). I'm wondering if the problem is that the project imported completely as source folders:
There are no packages to speak of. I created another project from scratch, and created the proper source folders and packages as needed
to match the package statements in the source code. After manually importing the source from the git repo, I can build and run that project.
If the lack of packages is indeed the problem, is there a quick way in Eclipse to convert source folders to packages?
What you did is you have probably cloned the repo in Eclipse and then Imported this project through a New Project Wizard, because in GitHub there is no existing .project (and no .classpath) files.
The "New Project Wizard" will create a set of defaults for a java project (I suspect that you selected just that), but is anaware of Maven structure, so all source folders will not be recognized and you will end up having to define them on your own. Worse, you will be unaware of any special parts of the Maven build that might be configured within pom.xml.
Because this project uses Maven for building, it would be better to use M2Eclipse while importing it. Install it using Help->Install new software.
Then there are a couple of steps required to make it use all Eclipse features.
Keep your cloned copy of the repository or clone again if you want to start from scratch. Then use File->Import feature to import a maven project into the workspace. Select Exisiting Maven Projects and point to the directory containing pom.xml file in the cloned repo. This will use Maven integration in Eclipse to generate .project and .classpath files based on pom.xml contents, so you will be able to more closely mimic Maven build in Eclipse. All source folders should be properly discovered this way. Eclipse might want to install some additional integrations for Maven features that this particular project uses. Let it, if that is the case.
Now, you will have the project operational and compiling in Eclipse, but it will not be aware that it is managed by Git... This is because M2Eclipse and Git Team provider are not integrated (at least they weren't when I last checked). In order to be able to commit to the repository in Eclipse, remove the project from workspace, but without deleting contents. Then, import from Repository view using Import Projects/Import exsisting Eclipse projects. Since necessary .project file is already generated, Eclipse will autodiscover the project and will use the right configuration prepared earlier by M2Eclipse.
In the end you will have a properly configured Maven project with Git as a team provider for it.
If this is a project meant to be built by Maven that contains a pom.xml file, install M2E before importing the project from your local cloned repository. It will handle this.
Right click at root of project select properties, in the sources tab add the folder "src/main/java" as source folder
Other way is to configure facet as java

Eclipse not recognizing files from SourceTree

My partner made a BitBucket git repository, and uploaded a Java project from Eclipse via SourceTree. I made my own project in Eclipse on my computer, and using SourceTree I pulled all the files from BitBucket. While these files show in Windows Explorer, they don't show in the Eclipse workspace. Is there a way to continue using SourceTree and Eclipse without using EGit, or is there no solution?
Could be because .classpath and .project files are registered in .gitignore so they didn't get checked in to git (that is right as well)
Your eclipse needs to regenerate those file based on your project type

Required Java libraries in Eclipse when working on multiple OSs

I'm developing an AppEngine project in Java.
I'm working on a MacBook and on other two PCs.
I'm using a hosted SVN as my RC.
I included some libraries from the GAE plugin in my project:
gwt-dev.jar, gwt-user.jar', validation-api-1.0.0.GA.jar.
I did that in the Java Build Path in the project properties.
Every time I switch a computer, I get an error:
Project '' is missing required library: ''. Off course, the path is changing between computers.
How can I resolve this issue?
Should I remove this settings from being stored on the SVN repository? If I shpould, how can I do that?
You should not persist any user-specific path information. Set your projects up by hand and then check out the user-agnostic stuff.
We have the same problem with IntelliJ. The answer is to check in only user-agnostic information, or get an IDE that's smart enough to use relative paths.
If you add 3rd party libraries to the project, make sure they are copied into your /lib directory and not in a path that's unique to you.
Create a project for the libraries.
Put the libraries in the project.
Export the jar files.
Set this newly created project as a dependency in the main project.

Categories