Search code examples
javaintellij-ideaconfigurationidejetbrains-ide

Running Java file in IntelliJ


I need some help with IntelliJ. I am fairly new to programming, and I have some experience with the IDE but I am by no means a know-it-all when it comes to IntelliJ.

I have 3 Java files (without their respective class files). When I open intelliJ it asks me:

  • Create New Project
  • Import Project
  • Open
  • Check out from Version Control

I click on open, IntelliJ opens up a file location, I click on one of the three Java files to open, and I drag the other two one by one (they open in their separate tab).

I cannot figure out how to run them. It is likely that I need to create run configuration and I don't know how to do it. I know how to create a new project and get everything working, but I don't know how I can get the files working if I just open them. Can someone tell me how to create the run configurations to run the files? Please and thank you.


Solution

  • Folders have to be marked as source root. Right click the project directory, and scroll down to Mark Directory As, and then select Source Root. Solved the problem for me.