Java Reference
In-Depth Information
Figure 4.14
The Configure Global Libraries
window demonstrates how a
library is defined by a collection
of class files, optional source
files, and optional JavaDoc files.
These files may be part of an
exploded directory or packaged
in an archive such as a JAR or
ZIP file.
process of configuring your
JDK
from chapter 1; you specify a set of class files and
then optional source and JavaDoc reference files.
Understanding class folders and JAR files
Every library must have at least one class folder or
JAR
archive added to it. When
you add a library to a module or project, you're adding the library's classes to its
classpath. Without class files, a library wouldn't do anything. Click the
Attach
Classes
button, and select a directory of class files or a
JAR
archive of class files to
add class path entries to the library. You may add multiple class entries if necessary.
Now, any module or project that uses this library will automatically recognize
the classes and include them in the classpath when running or testing your appli-
cation. Classes are all that is required to create a library, but if you attach source
code or JavaDoc entries as described next, you'll gain further advantages.
Adding library source code
If the source code for the classes in the library is available, you should use the
Attach Source
button to add it to the library, even if you only have a portion of it.
IDEA
won't attempt to use the source code to rebuild the library; it only uses the
source code to provide the same level of integration with libraries as it does with
your own classes. When source is available,
IDEA
can provide inline documenta-
tion through the use of JavaDoc it extracts from the source code; it can also use
the original parameter names in method signature help. In addition,
IDEA
lets
you drill down into the source code (marked as read-only) while editing.