Difference between static and dynamic class loading

Difference between static and dynamic class loading.

Static class loading:
This is done by using Java’s new operator.

For Example:
class myprogram
{
   public static void main(String args[ ])
   {
       program1 b =new program1();
   }
}
A NoClassDefFoundException is thrown if a class is referenced with Java’s “new”operator (i.e. static loading) but the runtime system cannot find the referenced class.

Dynamic class loading:
This is done by programmatically invoking the functions of a class loader at run time.

Class.forName (String className);
static method which returns a Class
The above static method returns the class object associated with the class name.
The string className can be supplied dynamically at run time. class.newInstance ();
A non-static method, which creates an instance of a class (i.e. creates an object).
What is Bootstrap,Extension and System Class Loader?
Class loaders are the part of the Java Runtime Environment that dynamically loads Java classes into the Java virtual machine...
Directory structure for a Struts folder
For using structs framework, directory structure is created in tomcat. Steps for creating directory structure are:...
What are action and action form classes in Struts?
Action classes are defined to handle request. Actions exist between Model and view of an application. The struts-config.xml file designates the Action classes that ...
Post your comment