Configure IntelliJ to compile Java files in a non-Java project


I have a catch all git repo that has code snippets from many technologies.  Javascript, Java, SpringBoot, Groovy, PHP, CSS, Bash, WSH.

One of the directories contains a java file I'd like to compile and run.

Is this possible?  As a work around, I copied the file to a Java maven project and compiled and ran it there.

I'm using IntelliJ Ultimate 2021.2.4

评论操作 固定链接

Just mark the parent folder of .java file as sources and set Java SDK for the module. 

评论操作 固定链接

Thanks Konstantin, it worked perfectly!