You can use a package that includes all of your essential classes and just import that package into any class where you want to use those classes. So basically, if you wanted to import the popular File class, you would use import java.io.File; but if you wanted to import the whole package you could say import java.io.*;
I've tried but failed to create a file of common classes that I can import! Here's what I did.
I'm using NetBeans 6.7.1 as my IDE.
1) I created standard Project:
File -> Java:Java Application -> Project Name: common.Code. I Left Create Main Class and Set as Main Project both checked. This created a package named "commoncode" with a main class of CommonCode.
2) I then added a file containing one of the classes I want use as common code.
3) I did a Clean and Build project.
4) In the output, the path for the jar was was listed. I copied the absolute path,including the jar file name, to my CLASSPATH.
5) I restarted NetBeans.
6) I then tried all these imports. None worked.
Thanks. Adding it to the project classpath worked. The thing I don't like is that it looks like I have to manually add it to the classpath of each project I build. How can I have it added automatically?