I am trying to build an installer for a Java application and would like to build a JAR which extracts itself. The JAR will be built using Maven assembly and will have a main class specified in the manifest. I want the main class to extract the rest of the JAR into a specified directory. The JAR will contain other JARs and some docs. I have found other questions, for example, (How to copy file inside jar to outside the jar?) but they don't address a self extracting JAR. I would like to know how to 1) obtain the location and name of the JAR from which the main is being executed, 2) copy the contents of the JAR into a specified directory.
UPDATE: I would also appreciate answers which address how to build an installer for a Maven Java application (using Eclipse) in general.