private static String getMacAppBundlePath() {
    String command = ProcessHandle.current().info().command().orElse(null);
    if (command == null) {
      return null;
    }

    Path p = Path.of(command).toAbsolutePath().normalize();
    while (p != null) {
      File infoPlist = Path.of(p.toString(), "Info.plist").toFile();
      if (infoPlist.exists() && infoPlist.isFile() && Path.of("Contents").equals(p.getFileName())) {
        p = p.getParent();
        break;
      }

      p = p.getParent();
    }
    return p == null ? null : p.toString();
  }
private static String getMacAppBundlePath()