Java Reference
In-Depth Information
In the
Configure Global Libraries
window, click the
Create Library
but-
ton to create a new global library.
6
Give the library an appropriate name (such as
Log4J
1.2.9
) in the
Library name
text field.
7
Navigate to the Log4J
JAR
file containing all the Log4J class files (typi-
cally, in the dist/lib directory under the log4j home; for example,
C:\jakarta-log4j-1.2.9\dist\lib\log4j-1.2.9.jar). Click
OK
.
8
Click the
Attach Sources
button, and select the src/java directory under
the Log4J base install directory as the source location. Click
OK
to com-
plete the operation.
9
Click the
Attach Javadoc
button, and select the docs/api directory under
the Log4J base install directory as the JavaDoc location. Click
OK
to
complete the operation.
10
Click
OK
to accept the new library definition.
11
Ensure the Log4J library has an enabled checkbox next to its entry in the
Used Global Libraries
section of the panel. Enable it if it isn't already so.
12
The library is now configured and available within the scope of your module. To
prove it, return focus to the editor pane, and select the
Go To | Class
menu
option (
Ctrl+N
). Type in the word
Logger
, and it will highlight in red, indicating
that there's no such class in your module—but select the
Include non-project
classes
checkbox, and
IDEA
will find a series of classes starting with
Logger
in
your libraries, the first of which is
org.apache.log4j.Logger
. Accept the choice by
pressing
Enter
, and
IDEA
will open that file—a non-editable source file found
within a referenced library—in the editor window.
In version 5.0, if the requested class isn't found in the project,
IDEA
searches in
nonproject classes automatically, without your needing to explicitly select the cor-
responding checkbox.
5.4.2
Improving and running the ACME project
Let's make
CommandLineClient
a little more intelligent. You already know that it
expects two arguments: the two currencies for which the exchange rate is being
queried. The client requests a rate from the service only if both arguments are
specified. Let's modify the application so that if a third argument is provided, it