I have a directory on my HD where I'd like to keep all of my self-created reuslable classes for import into other projects. The directory is: C:\JavaCode\ReusableClasses.
I tried putting C:\JavaCode\ReusableClasses in my classpath. I did this in Windows by selecting My Computer > Properties > Advanced > Environment Varables > Classpath.
However, every time I attempt to import a class from that directory into a new project, Eclipse complains that It can't resolve it. Eclipse then suggests to include the "ReusableClasses" project in the build of my current project. This works, but I'd like to simply be able to import my custom classes without this extra step. What am I doing wrong?
This environement variable is case sensitive. It is CLASSPATH, not Classpath.
Eclipse complains that It can't resolve it.
I don't think that Eclipse uses the Windows CLASSPATH variable. Right-click your project, click "Properties". Go to "Java Build Path/Libraries", click "Add external class folder". Select "C:\JavaCode\ReusableClasses" and click ok.
(If you really want them to be reusable, I think it would be better to package them in a JAR file)
I think that putting classes in a local directory like this does not make them reusable. Especially if you are making a web application. You'd better make a jar file, and import the jar file in your project.
Joined: Jan 24, 2010
I hate to sould like a TOTAL greenhorn, but how do I make a jar file? Can I do this using Eclipse, or do I need another utility?