Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert directories with java files to java modules in intellij

Tags:

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

like image 267
Michael Queue Avatar asked Nov 04 '15 20:11

Michael Queue


People also ask

How do I mark a directory as a module in IntelliJ?

Right-click a folder in the Project tool window. Select Mark Directory as from the context menu.

What is difference between module and directory IntelliJ?

a module is like a project, it produce jar file and can behave independently, but directory is part of a project and use to organize folders and classes.

How do I add Java files to IntelliJ project?

In the Project tool window ( Alt+1 ), right-click the node in which you want to create a new file and click New | File. Alternatively, select the node, press Alt+Insert , and click File. Name the new file and specify its extension, for example: File. js, and press Enter .


1 Answers

If you get the directory from some version system and it has a maven pom.xml configuration file, here's a solution:

  • Find the pom.xml in the directory.

  • Right click the pom.xml.

  • Then you can see the popup windows. Select the last item "add as maven project file".

  • Then, the maven build tool can automatically discern the directory as an module and import the specified jar dependencies.

like image 85
韩陈俊雪 Avatar answered Sep 19 '22 21:09

韩陈俊雪