Using loose class path web libraries support

The workbench provides loose class path web libraries support for your web projects.

About this task

Loose class path support is an optional mechanism that allows for the inclusion of Eclipse Java™ development tools class path artifacts in a web project's WEB-INF/lib folder. You can add dependences using the Deployment Assembly page, but you can also add the web libraries from the Libraries page under the Java Build Page. You can include JAR files, external JAR files, libraries, and variables. The project validator detects loose class path issues and reports them in the problems view.

Procedure

  1. Right-click your web project and select Properties > Java Build Path > Libraries.
  2. Select Add Jars, and select the JAR files that you want to add to your web project. Click OK.
    Add JAR files to Java build path
  3. Because these JAR files are added only to the build path and are linked as components, if you deploy this EAR/WAR or export this EAR/WAR none of these JAR files are included. A warning message appears in the Problems view: Classpath entry /AddJars/AddJars1.jar will not be exported or published. Runtime ClassNotFoundExceptions may result.
    Classpath warning.
  4. Right-click the warning message and select Quick Fix. You can either:
    • Mark the associated raw class path entry as a publish/export dependency.
    • Exclude the associated raw class path entry from the set of potential publish/export dependencies.
    Quick Fix options
  5. If you look at the .classpath file, the JAR files are now either included or excluded from the dependencies:
  6. Right-click the web project, and select Properties > Deployment Assembly to see what JAR files are included as a web library dependency:
    Java EE Module Dependencies
    Also, you can add JAR files as a web library dependency by clicking Add:
    Add Java Build Path Entries