by Margrit Höhme, 2002 (java@mhoehme.de)
The JAR browser is a very simple browser. It shows how to access a web site packed into a jar file. A JAR browser can be handy as a custom help for a Java application: The help files can be packaged as a single JAR.
The main features of the JAR browser are:
javax.swing.JFrame,
using
javax.swing.JEditorPane and
javax.swing.text.html.HTMLEditorKitjavax.swing.event.HyperLinkListener
The Java API for java.net.URL.openConnection() says:
If for the URL's protocol (such as HTTP or JAR), there exists a public, specialized URLConnection subclass belonging to one of the following packages or one of their subpackages: java.lang, java.io, java.util, java.net, the connection returned will be of that subclass. For example, for HTTP an HttpURLConnection will be returned, and for JAR a JarURLConnection will be returned.An example for an URL to a JAR file can be found in the Java API for
java.net.JarURLConnection:
jar:http://www.foo.com/bar/baz.jar!/COM/foo/Quux.classThis also works with local JAR files:
jar:file:/C:\projects\jarbrowser\site.jar!/index.html(Pay attention to the slashes and to the exclamation mark!)
The JAR browser works fine with any kind of relative hyperlinks. The web site may contain images as well as subdirectories.
Last modified: