Skip to content

Importing Koans source into an IDE

matyb edited this page Mar 24, 2013 · 5 revisions

To get the ball rolling and learn java in a fast and hopefully enjoyable manner, just keep reading and follow along.

Required: Download and install an appropriate JDK (a JRE is not enough). As of 2011, Java 7 is just over the horizon, but 6 (or even 5) is adequate for now. http://www.oracle.com/technetwork/java/javase/downloads/index.html

Configure your JAVA_HOME environment variable. http://www.google.com/search?q=configure+java_home

When learning a language, an IDE is useful. Some argue it is too useful and can prevent you from learning the true meaning of what's going on with your code. It's up to you whether or not to use an IDE, but the principle author of the java koans would highly recommend looking into eclipse which is available from http://www.eclipse.org.

Gettin Goin: Download the java koans source code. Current stable build is always retained in the master, while branches represent experiments adding new functionality or making changes. If you're new, the master branch is the ticket - but if your a bit seasoned and wish to pitch in go w/ a fork. Better yet - make your own fork. OK, let's walk before we run eh?

Grab the source from https://github.com/matyb/java-koans/archives/ using your favorite web browser and unarchive it in a location on your hard drive.

Eclipse Users: Open Eclipse and (if it is your first time) you will be asked to setup a workspace. You can make this whatever you would like, the default is fine - it need not be the directory you unarchived the code.

After selecting a workspace location you will likely see a screen like this: Welcome, yeah mehWelcome, yeah meh

Go ahead and goto your workspace, forget the tutorials - that's the purpose of the koans. If it looks different no fret, just click the x in the corner of the welcome tab and you'll goto the typical view to edit the code in:

I close the tasklist and outline views to free more space for the console and the text editorI close the tasklist and outline views to free more space for the console and the text editor

Click the File menu from the top and select Import.

Next - select "General -> Existing Projects into Workspace"

Browse to the path you unarchived/cloned the repository and select that. It should find 5 projects. Once imported they should compile successfully.

Lastly - right click the "koans-tests" project and select "Run As -> JUnit Test". Tests will fail, but that's ok, we haven't run them in the right directory for the class loaders to bind to all the app directories. That can be fixed by opening the run configuration that was created by running the tests and going to the Arguments tab and at the bottom for the Working Directory, select "Other" and enter the path to the unarchived koans project, and within that path select \java-koans\koans. Now Apply and run, and you should see green tests.

There you go! At this point you should have the projects in your workspace. Now for running you can still run the koans/src/run.sh or koans/src/run.bat - but you may now use the AppLauncher.main directly as well.

Clone this wiki locally