Where can I find jar file? code example
Example 1: java get location of jar file
//this worked for me
File jarDir = new File(ClassLoader.getSystemClassLoader().getResource(".").toURI());
//this didn't work for me but it is often suggested
File jar = new File(MyClass.class.getProtectionDomain().getCodeSource().getLocation().toURI());
Example 2: create a JAR file containing the class file
jar cvf jar_name.jar class_you_want_in_jar.class