An application could be started from a command line using its main class e.g. TestMain.main()
or from Launcher.main()
similar to the the above example. The application behavior in both cases is identical if resources are loaded from a file system. Starting from Launcher.main()
is required only to start the application from a JAR file which contains other JARs or native libraries.
Special handling is required for loading external LaF classes. Call the method JarClassLoader.loadLookAndFeel();
to preload UI classes.
Known issues: temporary files with loaded native libraries are not deleted on application exit because JVM does not close handles to them. The loader attempts to delete them on next launch. The list of these temporary files is preserved in the "[user.home]/.JarClassLoader" file.
See also discussion "How load library from jar file?" http://discuss.develop.com /archives/wa.exe?A2=ind0302&L=advanced-java&D=0&P=4549 Unfortunately, the native method java.lang.ClassLoader$NativeLibrary.unload() is package accessed in a package accessed inner class. Moreover, it's called from finalizer. This does not allow releasing the native library handle and delete the temporary library file. Option to explore: use JNI function UnregisterNatives(). See also native code in ...\jdk\src\share\native\java\lang\ClassLoader.c @version $Revision: 1.24 $
|
|
|
|
|
|
|
|