Try executing mvn eclipse:eclipse
to create the .project
and .classpath
files for Eclipse. Then import the project via Eclipse. All required libraries should then be on the classpath.
Here's the resulting .classpath
file:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/test/java" output="target/test-classes" including="**/*.java"/>
<classpathentry kind="src" path="src/main/java" including="**/*.java"/>
<classpathentry kind="output" path="target/classes"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="var" path="M2_REPO/junit/junit/4.12/junit-4.12.jar"/>
<classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar"/>
<classpathentry kind="var" path="M2_REPO/org/javassist/javassist/3.21.0-GA/javassist-3.21.0-GA.jar"/>
<classpathentry kind="var" path="M2_REPO/com/fasterxml/jackson/core/jackson-annotations/2.8.5/jackson-annotations-2.8.5.jar"/>
<classpathentry kind="var" path="M2_REPO/com/fasterxml/jackson/core/jackson-databind/2.8.5/jackson-databind-2.8.5.jar"/>
<classpathentry kind="var" path="M2_REPO/com/fasterxml/jackson/core/jackson-core/2.8.5/jackson-core-2.8.5.jar"/>
<classpathentry kind="var" path="M2_REPO/com/google/code/gson/gson/2.2.4/gson-2.2.4.jar"/>
<classpathentry kind="var" path="M2_REPO/org/openjdk/jmh/jmh-core/1.17.3/jmh-core-1.17.3.jar"/>
<classpathentry kind="var" path="M2_REPO/net/sf/jopt-simple/jopt-simple/4.6/jopt-simple-4.6.jar"/>
<classpathentry kind="var" path="M2_REPO/org/apache/commons/commons-math3/3.2/commons-math3-3.2.jar"/>
<classpathentry kind="var" path="M2_REPO/org/openjdk/jmh/jmh-generator-annprocess/1.17.3/jmh-generator-annprocess-1.17.3.jar"/>
</classpath>
As you can see, Maven takes care of adding quite a few dependenices to your classpath.
Once the files are generated, I find the most convenient way to get Java projects that live within
Git repositories into Eclipse to use this approach:
- Open the Git Repositories View (Window → Show View → Other → Git → Git Repositories)
- Select 'Add an existing local Git Repository to this view'
- Select the location where you cloned the repository to locally
- Right click the repository in the Git Repositories View and select 'Import Projects'