2

I am using Eclipse Kepler for Java. Normally you can add internal/external .jars to a Java project in the build path located in the properties. Why, when I clone a git repo and import it into my projects, do I lose that ability? I don't understand. I kinda need to do that.

bkvaluemeal
  • 428
  • 1
  • 9
  • 23
  • Which ability specifically is lost, and how can you tell it's been lost? – nitind Jan 05 '14 at 05:17
  • http://stackoverflow.com/q/8486403/3161835 I can tell because when I right click the project and click properties that option isn't even there. – bkvaluemeal Jan 05 '14 at 05:29
  • Sounds like the project's .classpath file was not pushed to the repository, or something odd happened when you imported it. They're not "Maven" projects, are they? When you said "clone a git repo and import it into my projects", you meant you imported projects from the local clone, right? – nitind Jan 05 '14 at 05:31
  • ... I feel so stupid. After clicking around a bit more I found what I was looking for. It was not where I expected it to be. – bkvaluemeal Jan 05 '14 at 05:32
  • @nitind Yes, you are correct. I clone the repo to my machine and make a local copy. – bkvaluemeal Jan 05 '14 at 05:34

3 Answers3

12

This is probably because the .gitignore has been configured to ignore .jar

Open the .gitignore file and remove the line *.jar, you should be able to add it.

======

As an aside - usually, for Java projects .jar files are not committed to repository (as they are large & it can slow down repository cloning), instead maven or gradle is used to configure dependencies. Example - http://www.mkyong.com/maven/how-to-create-a-java-project-with-maven/

Then when you want to work with eclipse just run mvn eclipse:eclipse to generate the necessary files. .gitgnore is usually set up to ignore *.class, *.jar, .project, .settings, .classpath

First Zero
  • 21,586
  • 6
  • 46
  • 45
  • For those using intelliJ, you can use a plugin call .ignore , that allow you easily to select which files you want to be ignore or not , without having to configure it the file itself. – Roberto Fernandez Diaz Nov 08 '17 at 11:18
0

I found that if you open the run configurations and go to the Classpath tab that you can add internal/external .jars. The run configuration can be accessed by clicking Run > Run configurations. I added my .jar to the user entries. The bootstrap entry caused a null pointer.

bkvaluemeal
  • 428
  • 1
  • 9
  • 23
0

When a project relies on libraries/modules, it's best to use a build tool for dependency management. JVM ecosystem is dominated with three build tools: Gradle, Maven and Ant.

How it works: In a build script we declare dependencies of the project. This tells the build tool where to retrieve libraries/modules our project depends on. Dependencies are resolved at runtime; downloaded from a remote repository, retrieved from a local directory or if required another project to be built in a multi-project setting.

Sabina Orazem
  • 477
  • 4
  • 12