In This Tutorial, we will Explain the Features, Installation, and Working of IntelliJ IDEA – an Integrated Development Environment (IDE) for Java:
IntelliJ IDEA is one of the most popular and powerful IDEs for Java development. IntelliJ IDEA is developed and maintained by JetBrains.
What You Will Learn:
Introduction To IntelliJ IDEA
The IntelliJ IDEA IDE is rich in features and enables rapid software development. This IDE also improves the code quality.
Click here for the official website of IntelliJ IDEA IDE.
IntelliJ IDEA IDE is available in two different editions.
- Community Edition: open source (free)
- Ultimate Edition: commercial
A detailed comparison of these two editions along with the features they support is enlisted below for your reference.
Comparison Between IntelliJ Community Vs Ultimate Edition
|Index||Community Edition||Ultimate Edition|
|License||Open-source, free.||Commercial with a 30-day free trial period.|
|Technology & Framework Support||Android, Ant, JavaFX, Junit, TestingNG, Gradle.||Android, Ant, JavaFX, Junit, TestingNG, Gradle, EJB, Spring, Struts, Node.js, Django, OSGi, etc.|
|Language Support||Java,Kotlin,Groovy,Perl, Python, XML, Go,Scala.||Java,Kotlin,Groovy,Perl, Python, XML, Go,Scala
|Deployment||Docker, Docker Compose ( via a plugin).||Docker, Docker Compose ( via a plugin), JBoss, WebLogic,Tomcat, Glassfish, Jetty, Virgo, etc.|
|Software Versioning & Revision control||GitHub, Git, CVS.||GitHub, Git, CVS,ClearCase, Perforce.|
|Build Tools||Maven, Gradle, Ant, SBT, Bloop, Fury (via Scala plugin).||Npm, Webpack, Gulp, Grunt, Maven, Gradle, Ant, SBT, Bloop, Fury (via Scala plugin).|
Features Of IntelliJ IDEA
IntelliJ IDEA is unique among all other Java IDEs with its deep insight into the code and context of the coder.
This IDE is designed around the coding principle that the developers should be able to code applications with as little distractions as possible. Thus in the case of IntelliJ IDEA, you have only the editor visible on the screen and for all other coding-unrelated functions, you will have dedicated shortcuts.
Let us now discuss some of the important features of IntelliJ IDEA.
- Smart code completion: IntelliJ IDEA provides a list of symbols applicable to the code that are most relevant in the current context and supports context-based code completion.
- Chain code completion: This is yet another advanced feature. The symbols that are provided by methods or getters and those applicable to the current context are listed by the Chain code completion feature.
- Static member’s completion: You can add static methods and constants and the IntelliJ IDEA IDE will automatically add the required import statements to the code in order to avoid a compilation error.
- Duplicates Detection: There can be duplicate code fragments in the code and this feature provides notifications or suggestions to the programmer about them.
- Editor-Centric environment: While coding, you also get quick pop-ups that help you in checking additional information without leaving the current context.
- Inspections and quick-fixes: IntelliJ IDEA pop up a little light bulb on the line of code where it has detected that you are about to make a mistake. When you click this light bulb you will see code suggestions list.
- Shortcuts for everything: As mentioned earlier, as programmers have fewer distractions, IntelliJ IDEA provides shortcut keys (keyboard shortcuts) for nearly everything, including actions like rapid selection and switching between various tool windows and many other operations.
- Inline Debugger: You can make use of Inline debugger to debug your application in IDE itself, hence making development and debugging processes more efficient.
IntelliJ IDEA software can be downloaded from the following link.
Download: IntelliJ IDEA
When you click on the above link, you will see the following page.
You can download either of the two editions but only the Ultimate edition has a 30-day free trial period. Once the required edition is downloaded, you can begin the installation.
The following are the installation steps for IntelliJ IDEA.
#1) DoubleClick the IntelliJ IDEA installable (.exe) and begin the installation. The following dialog box will be displayed.
This is the initial setup dialog. Click Next.
#2) The dialog to choose the installation location (destination folder) is displayed below.
Specify the destination folder and click Next.
#3) The dialog to choose installation options will be displayed.
Here you can choose the desktop shortcut, associations, etc. Check/Uncheck the appropriate options as per your requirements and click Next.
#4) The next step in the installation process is to choose the Start Menu Folder.
Choose the appropriate folder and click Install.
#5) Once you click “Install”, the installation process will begin.
Once the installation process is completed, the completion dialog box will be displayed.
#6) This is the final dialog indicating that the setup of IntelliJ IDEA is completed.
The completion of setup expects a system reboot, hence as per your choice you can either reboot your system immediately or later. This completes the installation of IntelliJ IDEA.
Development Using IntelliJ IDEA
Let’s discuss the steps to execute a simple “Hello, World” program using IntelliJ IDEA. These same steps are applicable to other Java applications as well.
#1) Open IntelliJ IDEA and you will see the dialog shown below.
Click “Create New Project”.
#2) Once “Create New Project” is clicked, a “New Project” dialog is presented to the user.
As shown in the above dialog, you can select the type of project you want to create from the left pane of the dialog. After selecting the type of project as “Java” and providing other details, click Next.
#3) In the next screen, you will see the type of Java application that will be created. Here you can check the option “Create project from template”.
Once everything is specified, click Next.
#4) In the next screen, you can specify the name of the project, location directory, and package name.
Now click Finish and your new project is created.
#5) After the project is created, the IntelliJ IDEA workspace looks like the screen shown below.
As you checked the “Create project from template” you are presented with the Main.java file that has a Main class and main method inside the class.
Now replace the following line of code, inside the main method:
Once this is done, it’s time to build and execute the application.
Build And Execute
To build the application you just created, click on the “Build” option and build the project. When the build is finished, a status message to this effect is shown in the status bar of the IDE.
Next, execute the project. For this, you can select the menu option “Run” and select the appropriate option from there to run the project. Or you can select the “Run” option from the toolbar as shown inside the red circle in the following screenshot.
Once the project is executed successfully, you will see the output of the program in the bottom pane of the IDE. In this case, the message “Hello World!!” will be displayed as a result of the successful execution of the Java application.
Debugging The Application
Using debugging you will be able to trace the running code, inspect the state in which the code is and also inspect the flow of execution. The debugger offered by IntelliJ IDEA helps you to debug anything and everything right from the simplest code to complex applications.
Using the inline debugger of IntelliJ IDEA, you can perform various operations like Stop the execution of a program at any point, Step in and step out of any function, Set various breakpoints, Inspect and keep a watch on variables, Evaluate an expression in the program and so on.
Breakpoints in a program allow the program to stop at certain points. Breakpoints are triggered when the execution of the program reaches the line where the breakpoint is set.
In the screenshot below, the breakpoint is specified in the first line of code in the main function. It is denoted by a red circle against the line number.
You can specify the breakpoint in your code by selecting the appropriate menu option (toggle breakpoint) from the “Run” menu or using the combination keys “Ctrl+f8”.
Once the breakpoint is set, you can start debugging the program either by selecting the “Debug” option from the “Run” menu or using a combination key “Alt+shift+f8”. This will prompt you with debug options to either debug the main or any other function.
There is also a debug option in the toolbar to start debugging. Once debugging is started, the following screen is displayed.
As shown in the above screen, a debugger tab window is displayed. You can perform various other operations like Inspecting the variable values, Evaluating expressions, Step into the function, Step out of the function, Stop debugging, Resume debugging, etc.
Using these operations you can effectively debug the application and identify the problem with the application.
IntelliJ vs Eclipse
Let us discuss some of the main points that differentiate IntelliJ IDEA from other popular Java IDE – Eclipse.
|Multiple Languages||Not so extensible. Supports few languages and you have to work with it.||You can have an exotic combination of languages of our choice and everything will work efficiently.|
|Multiple Projects||Cumbersome even to open multiple modules of the same project.||Can easily open multiple projects at the same time.|
|Ease of use||Easier to use as intelligent operations are supported.||Can be difficult for new programmers.|
|Code Completion||Very fast as supports context-based code completion.||It does not support context-based code completion.|
|Refactoring||Supports intelligent refactoring. You can get suggestions just by hovering the mouse.||Does not support intelligent refactoring.|
|Usability||Easier to learn IntelliJ IDE.||More difficult to assimilate all the features.|
|Performance||Can be a bottleneck when large projects are involved.||Handles large projects efficiently and open them faster.|
|Debugging||Easier debugging. Just point to the expression or any other element you want to debug and IntelliJ understands and shows possible suggestions.||You need to explicitly select the expression which you want to debug. It makes it a slow process.|
|Plugins||Supports only 727 plugins so far.||Easier to extend and supports as many as 1200+ plugins.|
|Cost||Free and open-source; also offers paid edition.||Free, open-source.|
This completes our tutorial on the IDE, IntelliJ IDEA. We have discussed various topics like features, downloading and installing the IDE as well as development and other operations like debugging. We have discussed the main difference between the two IDE’s i.e. IntelliJ IDEA and Eclipse.
Eclipse is easily extensible and it is easier to add plugins to Eclipse, it can be viewed more like a collection of plugins than a full-fledged IDE. IntelliJ IDEA, on the other hand, has intelligent auto-completion and refactoring features that make it easier to use especially for new programmers.
Debugging is quite simple in IDEA when compared to Eclipse. But when it comes to complex and bigger projects, Eclipse takes an upper hand. Thus, in a nutshell, both the IDEs have their own pros & cons and can be useful in their own way.
Stay tuned for more Java tutorials!!