Question: Good day,

I want a function to check if there are any files inside a folder, if there is no folder, make the folder and then run itself (function) again.

```js
const fs = require('fs');
const writeFileAtomic = require('write-file-atomic');

class DataHandler {
    constructor() {
    }
}

DataHandler.prototype.checkDB = function() {
    return new Promise((resolve, reject) => {
        fs.readdir('./database', function (err, files) {
            if (err) {
                if (err.code = 'ENOENT') {
                    fs.mkdir('./database', () => {
                        return this.checkDB;
                    })
                } else {
                    reject();
                }
            }
            if (files) {
                console.log(files)
            }
        })
    })
}

module.exports = DataHandler;

```

I get errors using this, saying this.checkDB is not a function

Answer: 
You can't write to files inside your JAR file, because they aren't actually files, they are ZIP entries.

The easiest way to store configuration for a Java application is to use [Preferences](https://docs.oracle.com/en/java/javase/18/docs/api/java.prefs/java/util/prefs/Preferences.html):

```
Preferences prefs = Preferences.userNodeForPackage(MyApp.class);

```

Now all you have to do is use any of the get methods to read, and put methods to write.
There is absolutely no need to write files into your resource folder inside a jar. All you need to have is a smart classloader structure. Either there is a classloader that allows changing jars (how difficult is that to implement?), or you just setup a classpath that contains an empty directory before listing all the involved jars.

As soon as you want to change a resource, just store a file in that directory. When loading the resource next time, it will be searched on the classpath and the first match is returned - in that case your changed file.

Now it could be that your application needs to be started with that modified classpath, and on top of that it needs to be aware which directory was placed first. You could still setup that classloader structure within a launcher application, which then transfers control to the real application loaded via the newly defined classloader.