- Forward


Loading Java Classes from a Remote Machine
An Introduction


Prof. David Bernstein
James Madison University

Computer Science Department
bernstdh@jmu.edu

Print

Recall
Back Forward
  • The Java Interpreter:
    • "Executes" the byte codes (i.e., the instructions for a hypothetical machine)
  • Obtaining the Byte Codes:
    • The interpreter obtains the byte codes that constitute a class using a class loader
A Brute Force Approach to Loading Remote Classes
Back Forward
  • The Approach:
    • Copy the remote class to the local file system
    • Then use the default class loader
  • The Shortcoming of this Approch:
    • If the remote class uses any other remote classes the default class loader won't find them
A Brute Force Approach (cont.)
Back Forward
javaexamples/classloader/HTTPClassRetriever.java
 
A Brute Force Approach (cont.)
Back Forward
javaexamples/classloader/HTTPApplicationLauncher.java
 
A Remote Class Loader
Back Forward
  • Approach:
    • Extend ClassLoader java.lang.ClassLoader
    • Override the findClass() method
  • How it Works:
    • The class loader will give its "delegation tree" a chance to find the class
    • If it can't be found, the class loader will load the class itself (by calling loadClass())
  • A Word of Caution:
    • Security is an issue
A Remote Class Loader (cont.)
Back Forward
javaexamples/classloader/HTTPClassLoader.java
 
A Remote Class Loader (cont.)
Back Forward
javaexamples/classloader/HTTPApplicationLoader.java
 
There's Always More to Learn
Back -