|
Jini PackagesA typical Jini package error looks like this:
Exception in thread "main" java.lang.NoClassDefFoundError:
net/jini/discovery/DiscoveryListener
The Jini class files are all in jar files. The Jini distribution puts them in a lib subdirectory when they are unpacked. There are a whole bunch of these jar files:
jini-core.jar mahalo-dl.jar sun-util.jar jini-examples-dl.jar mahalo.jar tools.jar jini-examples.jar reggie-dl.jar reggie.jar jini-ext.jar The jini-core.jar jar file contains the major packages of Jini:
net.jini.core net.jini.core.discovery net.jini.core.entry net.jini.core.event net.jini.core.lease net.jini.core.lookup net.jini.core.transaction If the Java compiler or runtime can't find a class in one of these packages, then you need to make sure that the jini-core.jar file is in your CLASSPATH . The jar file jini-ext.jar contains a set of packages that are not in the core, but are still heavily used:
net.jini.admin net.jini.discovery net.jini.entry net.jini.lease net.jini.lookup net.jini.lookup.entry net.jini.space If the Java compiler or runtime can't find a class in one of these packages, then you need to make sure that the jini-ext.jar file is in your CLASSPATH . The sun-util.jar jar file contains the packages from the com.sun.jini hierarchy. These contain a number of "convenience" classes that are not essential but can be useful. These are less frequently used. A compile or run of a Jini application will typically have an environment set something like this:
JINI_HOME=wherever_Jini_home_is CLASSPATH=.:$JINI_HOME/lib/jini-core.jar:$JINI_HOME/lib/jini-ext.jar |
||||
|
Chapter 14: Remote Events
Overview
This chapter also looks at how leases are managed by event sources. Finally, we'll look at how events can be used by applications to monitor when services are registered or discarded from service locators. |
||||
|
Images
The Swing package contains a convenience class called
ImageIcon
. This class can be
ImageIcon icon = null;
try {
icon = new ImageIcon(new URL("http://localhost/images/MINDSTORMS.ps"));
switch (icon.getImageLoadStatus()) {
case MediaTracker.ABORTED:
case MediaTracker.ERRORED:
System.out.println("Error");
icon = null;
break;
case MediaTracker.COMPLETE:
System.out.println("Complete");
break;
case MediaTracker.LOADING:
System.out.println("Loading");
break;
}
} catch(java.net.MalformedURLException e) {
e.printStackTrace();
}
// icon is null or is a valid image
|
||||