public void deletePlugin( final String pluginName )
    {
        Log.debug( "Deleting plugin '{}'...", pluginName );

        try ( final DirectoryStream<Path> ds = Files.newDirectoryStream( getPluginsDirectory(), path -> {
            if (Files.isDirectory(path)) {
                return false;
            }

            final String fileName = path.getFileName().toString().toLowerCase();
            return (fileName.equals(pluginName + ".jar") || fileName.equals(pluginName + ".war"));
        }) )
        {
            for ( final Path pluginFile : ds )
            {
                try
                {
                    Files.delete( pluginFile );
                    pluginMonitor.runNow( true ); // trigger unload by running the monitor (which is more thread-safe than calling unloadPlugin directly).
                }
                catch ( IOException ex )
                {
                    Log.warn( "Unable to delete plugin '{}', as the plugin jar/war file cannot be deleted. File path: {}", pluginName, pluginFile, ex );
                }
            }
        }
        catch ( Throwable e )
        {
            Log.error( "An unexpected exception occurred while deleting plugin '{}'.", pluginName, e );
        }
    }
Delete a plugin, which removes the plugin.jar/war file after which the plugin is unloaded.
@param pluginName the plugin to delete
xmppserver/src/main/java/org/jivesoftware/openfire/container/PluginManager.java