Search code examples
javaintellij-idea

Convert directories with java files to java modules in intellij


I recently switched to using IntelliJ. I manually imported some projects and I guess I didn't do it correctly. They are all supposed to be java modules but they are just regular directory folders. Is there a way to convert them to java modules so I can run the programs or will I have to manually recreate new modules?

enter image description here


Solution

  • There are a few ways to handle this. If your project has an existing build framework such as gradle, maven, etc, generally you can navigate to

    File > New > Project From Existing Sources...

    And then navigate to the gradle.build, pom.xml, or other framework specific build. When this project is created, all of the necessary source files should be properly identified.

    Alternatively, you can also manually set the source directories by selecting the directory in the Project window, right clicking and selecting Mark Directory As > Sources Root.

    See also: