6.3 Java Compiler Settings
The Java compiler settings enable you to control the problem messages produced by Eclipse while building your project. The problem severity level can be set to Error, Warning, or Ignore for more than 30 different conditions. These messages appear as markers within the generic Problems view, which also includes additional capabilities to sort and filter the messages (see Chapter 4, "Customizing Your Workbench").
Default compiler settings for all projects in the current workspace are assigned in the preference page category Java > Compiler. You have the option of overriding workspace preferences for the Java compiler with project-specific settings. The project properties dialog includes the Java Compiler page shown in Figure 6-10. Initially, the option to Use workspace settings is selected. Change this to Use project settings when you want to modify the problem messages for an individual project.
A common reason to modify these settings is when you are working on Java code from outside your team or from an open source repository. For example, the Unused Code tab is shown in Figure 6-10, where the Unused imports option is set to a default value of Warning. This option displays a warning message for each import statement in a Java source file that is not used within that class.
Figure 6-10 Use project-specific settings for compiler detection of unused code.
Other developers not working with Eclipse will often leave many unused imports in their code, sometimes leading to hundreds of warning messages when you create an Eclipse project containing that source code. It's best to leave this warning activated for your other projects, but you can eliminate the warnings in this single project by changing the option to ignore unused imports.
Your development team might also choose to establish very rigorous coding standards that rank unused imports as errors and issue a warning for unused local variables and unnecessary else statements. Set these coding standards as default Java compiler preferences and then export the preferences to a file that is imported by all team members.