code: public static Path update(Path applicationFile, Path updateDir, boolean removeUpdateFiles) throws IOException {
          Path newApplicationJar = null;
          // Extract the application name from the application file
          String applicationName = applicationFile.getFileName().toString();
          // Strip the extension
          applicationName = applicationName.substring(0, applicationName.lastIndexOf("."));
  
          ArrayList<Path> updateFiles = new ArrayList<>();
          try (DirectoryStream<Path> stream = Files.newDirectoryStream(updateDir, applicationName + "*.{jar,JAR,war,WAR,rar,RAR,ear,EAR}")) {
              for (Path entry : stream) {
                  updateFiles.add(entry);
              }
          } catch (DirectoryIteratorException ex) {
              // I/O error encounted during the iteration, the cause is an IOException
              throw ex.getCause();
          }
  
          if (!updateFiles.isEmpty()) {
              Path updateFile = updateFiles.get(0);
              newApplicationJar = Files.copy(updateFile, applicationFile, StandardCopyOption.REPLACE_EXISTING);
              if (removeUpdateFiles) {
                  Files.delete(updateFile);
              }
          }
  
          return newApplicationJar;
      }
docs: Update the application file with the content from the update directory.
  @param applicationFile The application file to be updated
  @param updateDir The update directory holding the new file versions
  @param removeUpdateFiles If true, the updated files are deleted from the update directory
  @return The path to the newly updated application file, or null if there was no update performed
  @throws IOException In case of an error