1//this worked for me
2File jarDir = new File(ClassLoader.getSystemClassLoader().getResource(".").toURI());
3
4//this didn't work for me but it is often suggested
5File jar = new File(MyClass.class.getProtectionDomain().getCodeSource().getLocation().toURI());
1return new File(MyClass.class.getProtectionDomain().getCodeSource().getLocation()
2 .toURI()).getPath();
3