Can't use Kotlin function in Java part of project

So I’m slowly adding Kotlin code to my existing java project, however, when I want to call a function from a KT file I run into some issues.

The Code:
image

I want to call this function from a java section in my project, so in order to achieve this I have to recreate the same function in a companion object like so:

image

And then in the java code (this code needs to run after pressing a button in a javaFX UI)

image

However, the moment I try to run I’m met with the following errors:

This is what the project structure looks like:

Am I just trying to implement this wrong? Or is calling a Kotlin function outside of Kotlin not a thing?

Back to the original part of the question, having Java call the main method is easy, no need to move to a companion function. Top level functions by default are put into a class based on the name of the file. You can modify that with an annotation. You can read about it here.

I would love to try this out, but right now the errors I was getting:

I get this errors everytime I try to change something about the code now and it refuses to compile now I have no idea why it’s acting like this now?

Edit: like the warning said I added:
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
<version>1.3.0</version>
</dependency>

And it seems to compile again now, slow steps.

Edit: Turns out that didn’t help if I even add a single println statement to my code it will start giving me errors again, what is this issue?

All of these Classes are Classes that are in single .kt files for instance “OverlayData” and “Window” are in a file “OverlayData.kt” Should I seperate them?

When I seperate them the issues seem to go away, however, I thought Kotlin supported having multiple class definitions in one file?

It seems like seperating classes also didn’t help as I’m still stuck with these issues now:

OK, I found out how to bandaid this issue, I have to tell IntelliJ to rebuild my project every single time I change a line of code otherwise it will start to error.