Wednesday, July 16, 2008

Including jar files in your projects in Eclipse*

Wednesday, July 16, 2008 7:36:43 AM (GMT Standard Time, UTC+00:00)

In previous posts, I've discussed how to include .jar files in the CLASSPATH variable. These settings work fine if you're coding in gedit (or SciTE) and using the javac and java commands, however, if using an IDE such as Eclipse you will get error messages when you include packages (or jar files) in your code. Below I outline how I solved this issue in Eclipse.

In Eclipse (version 3.4.0) go to the menu then 'Project'
In the panel on the left, Select 'Java Build Path'
In the 'Java Build Path' panel now loaded on the right Select the 'Libraries' tab
Click the button 'Add External JARs...'
Browse to your JAR file, select it then Click OK.
Finally, Click OK in the 'Java Build Path' panel to exit it

Eclipse should now (hopefully) recognise the included package and the errors should disappear. If this doesn't happen, possibly try to exit and reload Eclipse. This worked for me, so I hope it can do the same for you!

(PS. This was done on a Linux box, but I don't imagine Windows would be much, if any different.)

Related posts:
Learning LaTeX and Eclipse
How to set CLASSPATH (and PATH) for Java in Linux
How to set PATH and CLASSPATH for Java in Vista
Running Java classes with packages in Command Prompt

Comments are closed.