public static void unpackRNGFiles(Path serverPath) throws IOException {
        Files.createDirectories(serverPath.resolve("resources").resolve("schema")); // mkdir -p
        final String basePath = "resources/schema/";

        var resources = Thread.currentThread().getContextClassLoader().getResources(basePath);

        if (!resources.hasMoreElements()) {
            throw new IOException("Could not find RNG files in jar file!");
        }

        URL resourceURL = resources.nextElement();

        if (!resourceURL.getProtocol().equals("jar")) {
            throw new IOException("Unhandled protocol for resource " + resourceURL.toString());
        }

        String jarPath = resourceURL.getPath().substring(5, resourceURL.getPath().indexOf('!'));
        try (JarFile jarFile = new JarFile(URLDecoder.decode(jarPath, "UTF-8"))) {
            Enumeration<JarEntry> entries = jarFile.entries();
            while (entries.hasMoreElements()) {
                JarEntry entry = entries.nextElement();
                if (!entry.isDirectory() && entry.getName().endsWith(".rng") && entry.getName().startsWith("resources/schema")) {
                    Path writePath = serverPath.resolve(entry.getName());
                    try (InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(entry.getName())) {
                        BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
                        String content = reader.lines().collect(Collectors.joining(System.lineSeparator()));
                        Files.write(writePath, content.getBytes(), StandardOpenOption.CREATE);
                    } catch (Exception ex) {
                        // Ignore: unwanted .rng file
                    }
                }
            }
        }
    }
LemminX isn't quite able to use .rng files from inside a jar for validation.
We embed them in the fat-jar and unpack them to the server installation location on start.
This is similar to the documentation fetching in schema language-server.
integration/schema-language-server/lemminx-vespa/src/main/java/ai/vespa/lemminx/UnpackRNGFiles.java