実行可能 jar にエクスポートされたら、それがどこにあるかを知る必要がある Java アプリがあります。したがって、コードには次の関数があります。
        private void setLocalJarPaths() throws URISyntaxException{
             CodeSource codeSource = ShopRecipient.class.getProtectionDomain().getCodeSource();
             File jarFile = new File(codeSource.getLocation().toURI().getPath());
             localJarPath =  ShopRecipient.class.getProtectionDomain().getCodeSource().getLocation().getPath(); //getgetgetgetgetgetgetget
             localParentPath = jarFile.getParentFile().getPath();
        }
これは、Eclipse から実行しているときに機能しますが、実行可能な jar ファイルにエクスポートするとすぐに、次のエラーがスローされます。
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at java.io.File.<init>(Unknown Source)
    at bsReportSender.ShopRecipient.setLocalJarPaths(ShopRecipient.java:71)
    at bsReportSender.ShopRecipient.<init>(ShopRecipient.java:23)
    at
クラスを同じパッケージ内の別のクラスに変更しようとしましたが、それでも同じエラーがスローされます。何か案は?