Sunday, July 31, 2011

How to reference a .jar file in an intelij project.

I've been using IntelliJ to develop my Android game Bugsy. It's been excellent but when I started trying out Flurry I found referencing external .jar files to be a bit of a pain. It's really not obvious how to do this basic task.

I've tried a few different ways which seems to work but once my laptop was rebooted the compiler no longer finds the jar.  After a few rounds of trial and error here is a procedure that has stuck!

  1. Create a folder in your project ('jars' for example and drop the .jar file in there).
  2. Open Project structure dialog (you can tooltip-hunt the button but ctrl+alt+shift+s is easier).
  3. Click "Modules" on the left.
  4. Click the "Dependencies" Tabs
  5. Click the Add... button
  6. Choose 1. Single-Entry Module Library
  7. Browse your project for the file .jar file and select it
  8. Click OK then OK again to close the project structure.

Rebuild the project and get on with doing something much more fun!!

No comments:

Post a Comment