The trick mentioned in the quote is basically a way to give the user the illusion that the application loads faster by displaying a splash screen βimmediatelyβ after the program is called and only after that starts loading the classes.
Suppose the main class of your application is TheActualApplication . So, if you create a FastSplash class to run your application, the splash screen may appear earlier than when SlowSplash used as the main class.
public class FastSplasher { public static void main(String[] args) { SplashWindow.splash(Splasher.class.getResource("splash.gif")); SplashWindow.invokeMain("TheActualApplication", args); SplashWindow.disposeSplash(); } } public class SlowSplasher { public static void main(String[] args) { SplashWindow.splash(Splasher.class.getResource("splash.gif")); TheActualApplication.main(args); SplashWindow.disposeSplash(); } }
The reason the splash screen may happen earlier when using FastSplash is because Java virtual machines today usually have lazy class resolution and thus you won't see much of a difference. If the class resolution is desired, the splash in SlowSplasher will be displayed only after all the classes used in TheActualApplication . In FastSplasher splash screen appears immediately because the TheActualApplication class TheActualApplication loaded dynamically at run time using reflection and cannot be solved statically and thus loaded at startup.
source share