Java Reference
In-Depth Information
age. Accomplish this task by merging the following code fragment into Listing 4-3 .
if (args.length == 3)
catch (ClassNotFoundException cnfe)
System.err.println("cannot load "+args[2]);
This code fragment, which must precede Package pkg = Pack-
age.getPackage(args[0]); , loads the classfile named by the revised Pack-
ageInfo application's third command-line argument. (I'll discuss
Class.forName() later in this chapter.)
Run the new PackageInfo application via java PackageInfo logging
1.5 logging.File andyouwillobservethefollowingoutput—thiscommandline
identifies logging 's File class as the class to load:
Name: logging
Implementation title: null
Implementation vendor: null
Implementation version: null
Specification title: null
Specification vendor: null
Specification version: null
Sealed: false
Exception in thread "main" java.lang.NumberFormatException:
Empty version string
at PackageInfo.main(
Itisnotsurprisingtoseeallofthese null valuesbecausenopackageinformationhas
been added to the logging package. Also, NumberFormatException is thrown
Search WWH ::

Custom Search