Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unbound classpath variable junit and log4j when importing a libgdx project in to eclipse

I'm trying to import and run the project listed here:

Scene2d Actions and Event Handling

I start by downloading the zip file and then importing it in to eclipse. From here I get the following three errors (after resolving others pertaining to incorrect android version):

Description Resource    Path    Location    Type
Unbound classpath variable: 'M2_REPO/junit/junit/4.5/junit-4.5.jar' in project 'game-test-desktop'  game-test-desktop       Build path  Build Path Problem


Description Resource    Path    Location    Type
Unbound classpath variable: 'M2_REPO/junit/junit/4.5/junit-4.5.jar' in project 'netthreads-libgdx'  netthreads-libgdx       Build path  Build Path Problem


Description Resource    Path    Location    Type
Unbound classpath variable: 'M2_REPO/log4j/log4j/1.2.16/log4j-1.2.16.jar' in project 'netthreads-libgdx'    netthreads-libgdx       Build path  Build Path Problem

Does anyone know how to resolve the problem? I have noticed that this junit should be included in the JDT for eclipse but I have installed that with no change in the error. Thanks.

like image 935
user1170304 Avatar asked Dec 06 '12 00:12

user1170304


1 Answers

The problem is that the project has dependencies on libraries which are managed with Maven, which Eclipse isn't automatically setup to handle.

You'll need to first download and then install Maven. Then you can open a command-line window and run mvn install from your project directory, which will build the code and pull down any required dependencies.

Lastly, you'll need to go into Eclipse and set it up to that it's aware of your local Maven repository...

  1. Window -> Preferences
  2. Java -> Build Path -> Classpath Variables -> New
  3. name will be M2_REPO
  4. path will be something like c:\users\drew\.m2\repository
  5. Click the OK button twice

If you do a recompile in Eclipse, those errors should go away.

like image 93
Drew Avatar answered Nov 15 '22 07:11

Drew