Eclipse IDE and jar files

P

Peter Parker

Hi,

At work, I see a number of Java files that do not have the 'import'
statements (such as "import org.apache.commons.lang.StringUtils") and so
Eclipse IDE 3.1 gives context-sensitive error message like 'StringUtils
cannot be resolved on lines where StringUtils are implemented. Is there a
way (to set up the classpath?add jar files? create user library?) in Eclipse
IDE to reference the jar files (commons-lang-2.1.jar, for example) so that
the import statements are not needed? Could someone show me how? Thank you.
 
J

jagonzal

Peter said:
Hi,

At work, I see a number of Java files that do not have the 'import'
statements (such as "import org.apache.commons.lang.StringUtils") and so
Eclipse IDE 3.1 gives context-sensitive error message like 'StringUtils
cannot be resolved on lines where StringUtils are implemented. Is there a
way (to set up the classpath?add jar files? create user library?) in Eclipse
IDE to reference the jar files (commons-lang-2.1.jar, for example) so that
the import statements are not needed? Could someone show me how? Thank you.

You could get rid of the imports if you use the FQN of every external
class in your code. Imports are cleaner.

The problem you describe is fixed by opening the project properties,
going to "Java Build Path", and selecting the "Libraries" tab. There
you can add your external jars, and the imports will actually work.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top