Helping ordinary people create extraordinary websites!
HOME TUTORIALS SCRIPTS WEB HOSTING BLOG FORUM
Get Our Newsletter
Email:

Simplify Your Application Delivery with One-JAR

By P. Simon Tuffs
2005-04-22


Bootstrapping the JarClassLoader

You probably just have one remaining question at this point: How did I insert the JarClassLoader into the launch sequence so that it could start loading classes from the One-JAR file in the first place? The precise details are beyond the scope of this article; but ,basically, instead of using the main class com.main.Main as the META-INF/MANIFEST.MF/Main-Class attribute, I created a new bootstrap main class, com.simontuffs.onejar.Boot , which is specified as the Main-Class attribute. The new class does the following:

• Creates a new JarClassLoader.

• Uses the new loader to load com.main.Main from main/main.jar (based on the META-INF/MANIFEST.MF Main-Class entry in main.jar).

• Calls com.main.Main.main(String[]) (or whatever the name of the Main-Class is in the main.jar/MANIFEST.MF file) by loading the class and using reflection to invoke main(). Arguments passed on the One-JAR command line are passed through to the application main method without modification.

Tutorial Pages:
» Power Programming with Custom Classloaders
» Overview of One-JAR
» Problems and solutions
» Enter the JarClassLoader
» Loading Resources
» Bootstrapping the JarClassLoader
» In Conclusion
» Resources


First published by IBM DeveloperWorks


 | Bookmark
Related Tutorials:
» All about JAXP, Part 1
» Make Database Queries Without the Database
» Load List Values for Improved Efficiency
» 2 Ways To Implement Session Tracking
» A Simple Way to Read an XML File in Java
» Develop Aspect-Oriented Java Applications with Eclipse and AJDT