Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Libraries, projects, modules and packages in Intellij Idea

I'm a beginner programmer and I'm learning how to work with Intellij IDEA. A project in IntelliJ IDEA has some different structures like libraries, modules and packages.

Can someone explain what the difference is between those structures and when to use a particular structure? e.g. I can't choose my package name (of a class) arbitrarily when it's already part of a module. What is the connection between those? I'm primarily having difficulties understanding the difference between a package and a module. (characters)

like image 865
Michiel Van Couwenberghe Avatar asked Jul 24 '13 16:07

Michiel Van Couwenberghe


People also ask

What are libraries in IntelliJ?

A library is a collection of compiled code that you can add to your project. In IntelliJ IDEA, libraries can be defined at three levels: global (available for many projects), project (available for all modules within a project), and module (available for one module).

What is project and module in IntelliJ?

In IntelliJ IDEA, a module is an essential part of any project – it's created automatically together with a project. Projects can contain multiple modules – you can add new modules, group them, and unload the modules you don't need at the moment.

What is the difference between module and package in IntelliJ?

A Module can reference a library which can be a project library or a global library. Global libraries have to be defined only once. Project library in every project you need them. Packages are a java concept and are IDE independent.


1 Answers

A project in intellij consists of modules. Modules can be java modules, or android modules or whatever. Modules contain your java code and all that stuff. A Module can reference a library which can be a project library or a global library. Global libraries have to be defined only once. Project library in every project you need them.

Packages are a java concept and are IDE independent.

Lets say I wanna do a little game. I would create a intellij Project called "mySuperGame". Then I would create two java modules from intellij, called "logic" and "ui". In the module settings of "ui" I would specify a project library to use opengl and a dep. to "logic". The package name of my logic classes would be "com.mysupergame.logic.XXX".

See http://confluence.jetbrains.com/display/IDEADEV/Structure+of+IntelliJ+IDEA+Project for more information.

like image 155
morpheus05 Avatar answered Sep 19 '22 18:09

morpheus05