code: public String autoDetectPackageName(final File file) {
          try {
              final Set<String> packageNames = new HashSet<>();
              try (JarFile jarFile = new JarFile(file)) {
                  final Enumeration<JarEntry> entries = jarFile.entries();
                  while (entries.hasMoreElements()) {
                      final JarEntry entry = entries.nextElement();
                      String name = entry.getName();
                      if (name.endsWith(".class")) {
                          logger.debug("Considering package of entry '{}'", name);
  
                          final int lastIndexOfSlash = name.lastIndexOf('/');
                          if (lastIndexOfSlash != -1) {
                              name = name.substring(0, lastIndexOfSlash);
                              packageNames.add(name);
                          }
  
                      }
                  }
              }
  
              if (packageNames.isEmpty()) {
                  return null;
              }
  
              logger.info("Found {} packages in extension jar: {}", packageNames.size(), packageNames);
  
              // find the longest common prefix of all the package names
              String packageName = StringUtils.getLongestCommonToken(packageNames, '/');
              if (packageName == "") {
                  logger.debug("No common package prefix");
                  return null;
              }
  
              packageName = packageName.replace('/', '.');
              return packageName;
          } catch (final Exception e) {
              logger.warn("Error occurred while auto detecting package name", e);
              return null;
          }
      }
docs: Auto-detects a package name based on a JAR file's contents (finding the
  common denominating package path)
  
  @param file
  @return