Chapter 3. Java projects with Eclipse

Table of Contents

3.1. Basic adjustments

Figure 3.1.  Preference – New Project

Ensure that the source code remains separate from the produced class files. To do so, change the source folder name to „src“ and the output location to „bin“ in the dialogue Window - Preferences.

For web services it is even better to set the output directory to the path, where the application server expects them („WEB-INF/classes“). You can also adjust this setting in Project-Preferences for each project separately.

Figure 3.2.  Properties – Build output folder

3.1.1. Classpath Variables

Beside the Java runtime library you have to include other libraries in nearly every project. Since each developer might install them in different paths, you should use classpath variables.

Figure 3.3.  Preferences – Classpath Variables

In the project only symbolic names are stored. Each developer can adjust them to his local setting. If you need e.g. „servlet.jar“ from Tomcat, it will be referenced in the project as „TOMCAT_HOME/common/lib/servlet.jar“. The actual installation path of Tomcat will be defined by each developer setting the value of classpath variable TOMCAT_HOME corrosponding to his local installation.

3.1.2. Name versioning

If you develop in a team and use relatively new technologies, tool versions and their libraries change rapidly. To avoid chaos and strange side-effects, which even look different for each team member, it is very important that everyone uses the same tool versions.

Therefore I recommend to use names with a version number in it e.g. „castor-0.4.1.jar“. If all libraries in the project are referenced this way, it is guaranteed that all developers use the same versions.

3.1.3. Extend the documentation

You can extend the included documentation very easily with your own texts. You can include all javadoc API documentation. This applies to Java sdk and additionally to a any library used in any project.

Plugins can also include their documentation smoothly - an example is this article which is available as „documentation plugin“ in the download area. If installed, this article will be available and searchable in the Eclipse help viewer.

Figure 3.4.  Properties for a library

To get most support you should assign the API documentation (javadoc) and even the source code (if avialable) to every library used in the project. If you install a complete java sdk, Eclipse will recognize this automatically. Assign the documentation and sourcecode archives in the Properties of each JAR (available in the context menu) for all individual libraries.

Accordingly the API documentation of your own project is included:

Figure 3.5.  Properties – include own documentation

Setup like this, press SHIFT + F2 to open the documentation for the current object or F3 to open the corresponding source file.