I use eclipse for my java coding and just imported some java source from git with below method.
(right click --> import --> projects from git)
it seems codes were downloaded successfully but I can't build it.
in menu bar, Project --> Build project is not working for my downloaded source.
someone said "check your project icon in the package explorer, your little "J" on the files is too faint it means you did not commit your project metadata files properly". how can I fix this issue? please refer my picture below(my current issue) and give me your kind advice.
my current issue
Personally, i always clone project from repository using terminal and command:
git clone <repo url>
and then in Eclipse, import existing project directly from hard drive.
Related
I cloned a project of my teams from Github using a link to my Folder Java. I only used the Clone tools in Eclipse and added it to my Package Explorer as a General Project. But when I open the project, all the package became normal folder, I click into the folder to the Build Path but there's nothing I can't do. I don't understand why, please help me!
If it's a Maven project using the smart import might help.
I'm trying to import a project on GitHub into eclipse because there are a few things I want to add to it. However whenever I add it I get a ton of errors and problems with it...
The GitHub project is https://github.com/dmulloy2/SwornGuns
I've tried adding it to eclipse and it didn't work. I then tried making a project in eclipse and then put the files in, that didn't work. I also read online that going to Configure -> Convert to Maven Project would work, and then importing the spigot.jar file that this source depends on. However that didn't work and just gives me a ton of import errors.
The errors I am getting:
That project is a maven project. A simple way is clone that project into your machine, and import it as a maven project, with File - Import - Maven - Existing Maven Project.
Eclipse will help you resolve the pom file and configure project and download necessary libs.
First, make sure you are using Luna, the most recent version.
In eclipse, File > Import > Git > Projects from Git > Existing Local Repository.
In the Import Projects from Git screen, click add, then goto the location of the cloned repository. Click open, finish, then next. Select Java > Java Project, and click next again.
At this point, there are three options.
Import existing projects
Use the New Project Wizard
Import as General Project
Pick "Use the New Project Wizard". Then, uncheck "Use Default location", and click browse. Select a folder (You probably want the location you cloned the repo to), click "Open", and give the Project a name. Click next, and make sure that the src/bin folders are setup correctly, and click finish.
Whew!
Of course, the Import from Git option was only added in Luna, so update eclipse if necessary.
I have just started using the built in GIT functionality of Eclipse and I have everything set up and working, my problem as of now is that I realized my project that I imported from GIT is not reporting errors in my Java like the local copy would. I've tried the following,
Project -> Clean
When I right click on the property files of the folder I can't seem to choose a Java Builder.
It depends on how you import your Java (Git managed) project into the Eclipse workspace.
See "Importing a GitHub project into Eclipse" as an example.
The key is for your Eclipse project to reference the sources in the git repo folder (kept outside the Eclipse workspace folder, in any place you want).
I have some problems importing a Java project into my workspace. I am following this tutorial - however I can not use the final Import existing projects step because the GIT repository I use does not include the Eclipse specific .project and .classpath files.
Use the New Projects wizard
Therefore the project is not recognizes as project and hence can not be imported. Therefore I tried my luck using the option Use the New Projects wizard and select "Java Project" in the next dialog. The problem is that this creates a new Java project without any content!
The project is also not connected to the GIT repository.
Edit: This is a known bug of eGIT: Bug 324145 - Project import doesn't work for abitary project types - if you want this problem fixed vote for it...
Import as general Project
If I use Import as general Project Eclipse always wants to use the external repository directory as project directory which is not what I want and additionally the created Project is not Java-enabled.
Therefore I am asking why it is so complicated to import a Java project into Eclipse using eGIT?
It is possible by first cloning the repository and then creating a General project based on that. Then you can convert it to Java project. Here is how:
First go to File>Import...>Projects from GIT.
In the Select a Git Repository view you first press Clone. And follow instructions. This will create a local "checkout" of the repository to your computer. You can set the folder to be your workspace so it looks like any other of your eclipse projects.
After you have cloned the repository you get back to Import-view. Now you can select the repository you just cloned from the list.
Click Next and select Import as General Project. Now you have a git repository to eclipse.
Convert it to Java project: Add nature and buildCommand elements from other Java project to your .project file:
Relevant sections from .project:
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
Then from Project>Properties>Java Build Path>Source add your source folders (and possible libraries).
Edit: Added the conversion to Java project.
With Git (especially EGit) your 2 best options are:
1) Create a java project in eclipse, and then create a linked folder to where the source lives in your git repository (mentioned by #mattb). I don't think EGit will connect to your git repo easily in this mode, but your eclipse specific project files will be in a different location than your source tree.
2) Create your java project and let it point to the external git repo (which you mentioned). It will create a .project and .classpath file where your source lives. Then using Team>Share Project will allow you to connect EGit to the already existing git repo.
Option 2 (which I use) allows the tools to work with java projects in a git repo reliably.
May not be applicable to your project but if you are using Maven in the project, you can import it as Maven Project from Eclipse if you have m2e installed, this way all the needed files like .project, .classpath will be generated. I think that is a good approach because if your pom.xml is well-written, it can contain all the needed information about the project such as build target directory, classpath, java version etc., and it will probably work with most of the populer IDEs.
I suggest to get used to use Maven on every java project, even for a simple hello world application because I see it as some sort of "standardization" for Java projects.
Create a new project in eclipse and just point the source directory at the existing sources, rather than the default path.
here I saw all methods to import a non eclipse project into eclipse(open source git projects into eclipse) ... no need to copy .project or .classpath file to copy ... here is the step by step process-
Step 1. import the project from git. Paste the URL and import the project as a general project.
Step2. If you want to import it as a maven project you should have m2e plugin installed in your eclipse(eclipse marketplace).
Step3. Now we should convert this general project into eclipse project.So right click on project ->properties->ProjectFacets. click on ConverttoFacetedform
Step4. Now if your project is a web project.See the left side window.. there is an option DynamicwebModule ... check it (leave it if it's not a webproject).... On the rightside window .. go to runtimes tab. Now check the server and JDK version both.. apply Ok.
Step5. If it's a maven project .. then right click on project congigure->convert to maven project->Finish
Steps:
Import project as a normal git project
Right click on the project and select Configure -> Convert to Faceted From
Now Select Faceted whichever you want to choose for simple java project just select Java from the Check box List
you can add more configurations based on your requirement under runtime tab on left and under "Further configuration available.." link below the pane. you can skip this step if no additional configuration required and you just need a simple java project.
click on apply and then apply and close.
It will convert your simple git project to simple java project of Eclipse.
-- Happy coding :)
I have a that uses maven... and I want to put it in my working environment with eclipse(Galileo)... the project is in a svn server, and I can create check out the project and everything looks OK. I even can run the unit test and everything is working there.
However, now that everything is there I wanted to work in the code, and oh surprise there are no packages in my project... I mean all the source code is in the src folder and browsing through it i can see all my files, ut if I open the files from there, the files are opened as text files with no coloring, but worst no help at all about errors in compilation.
I don't know what im I doing wrong now, because I had the same project in other machine and it was working well.
So here is what I did, please let me know if you notice if I did something wrong, miss any steps or anything that can help me:
In the SVN Repository (Using subclipse 1.6.10) I added my SVN Repository
Browsed to the folder where I have the pom file
Right Click> Check out as a Maven project...(Using m2eclipse 0.10.020100209)
Used the default options and finish.
The projects were created with no problem. I said projects because this maven project has modules, and each module became a project in eclipse.
Back in the java perspective, Right click in the project, Run as > maven test(Using JWebUnitTest, because I am testing a servlet)
BUILD SUCCESS!!
But as I said there is not packages so I can't really develop in this environment.
Any help??
Thanks!
When performing a svn checkout as maven project, m2eclipse writes what it does in a console window, accessible using the "console" panel, where there is a drop-down list of all available consoles. What does this console tells ?
Besides, if you can perform a maven test, you can also, in the maven menu (of your contextual menu) do a "update project configuration" which should do the same thing and configure eclipse for your project.
As a last test, is there a maven icon over your project ?
Have you tested your setup on command line with Maven ? Does a mvn package work without errors ? The location for the sources in Maven is src/main/java + Package name. Have you opened the project as a Maven project?
Thanks for your help, however I noticed that eclipse itself was behaving weird when I try to create a package there and I didn't have the option.
So I found out that for some reason that eclipse installation wasn't giving me any of the Java basic options.
So I download a new eclipse installation.. and I repeat the whole process and now is working...
No clue what was the problem with this eclipse because I was using it for other projects and I don't know when I lost the basic functionalities!
Thanks anyway!