Its quite simple. Try using the below code.
return new File(AbcClass.class.getProtectionDomain().getCodeSource().getLocation().toURI()).getPath();
Just replace the “AbcClass” with your own class name and execute it, to get the desired results. Hope this helps!!