Now that you know the advantage of using an Integrated Development Environment, let’s download one. You can now download IntelliJ using the link given here.
On this website, you will see two versions; one is the Ultimate version and the one is the Community version. Please download the Ultimate version free trial for now. Also, you will see the links for versions of the macOS, Linux, and Windows. Click on the version as per your computer and operating system requirement.
While installing the IDE, you will see a dialog box that will ask you if you want to purchase it or evaluate it for free. You can click ‘Evaluate for Free’, which gives you a 30-day free trial of the Ultimate version.
Once the IDE is downloaded, double-click to install it. Once you click Finish, you will see a Complete Installation dialog box. Click “I do not want to import settings”. In the final dialog box, you can choose the theme you want, or you can keep all the defaults. And you are done!
You can download the following java file which you will need while watching the video. Right click on the java file and open it with IntelliJ.
To download it. You can see the sequence of screenshots and the link provided for Mac and Windows both. Note that here we are downloading the ultimate version and not the community version. Now that we have installed IntelliJ, let's open it and see. How do we use it. When you open it by clicking on the IntelliJ icon, it shows options like creating a project, import project and open a file. Projects are the ways with which you can group or organize a code that is more useful to you. Example you might want to keep the code to create a website separate from the code that designs a search engine. Projects help you with that. So we will create a new project. Then comes a window where IDE will ask for the Java SDK we want to use. The Java development kit we install will look useful to you now because this is the place where your ID asks for it. Sometimes ID automatically detects the JDK you installed. If not, click on this new button here and it will automatically navigate to the home directory of a JDK. Here we have few options which are some libraries which are code or functions which someone else has written. We won't be using them and we'll use Java inbuilt functions. So click OK and we are done. Next window will ask if you want to use a template. We will use it because using it will always give some already written code which makes writing programs a bit easy for us. This is like some default code which has to be there before we start writing the code we want to. You can also notice here that it's written as simple Java application that includes a class with main method. We will talk about this main method in detail later but if you remember that while writing hello world program on a notepad we wrote few lines for main function and class. Selecting this template. Make sure that once you are there on the platform, the class and the main function is already there. Click Next. We will be asked to give our project a name. Let's name it first program here. Next is the project location. This is the directory where our project is going to be saved. IntelliJ gives us some default location. If you want to change it, you can, else you can keep it same and continue. Next is package name. In case you are creating some application to distribute to some web or mobile device, a unique package name is required. We will keep it this way only for this example click Finish and there you go. You have your project set up.
Now we will write a code to print Hello World on this IntelliJ environment on the left you can see a main project layout named first program. When you expand it, you will see source which refers to the source code or the code in the main function over there on expanding source. You will see the base package name inside which you will see the main which refers to the class where all our functions and codes are written. We will learn about classes soon in the upcoming sections. For now, just keep in mind that inside this main class we will write all our functions and codes. Just like this class contains the main function, the main function contains the entire code. Both this main class and the main function you can see on the right side of the screen written in the form of the code. Just advising you again not to worry about this main function and the class right now as you are going to learn about this all soon. Now since all our code is supposed to be written inside the main function contained by the main class, the cursor by default points there. We will write the print command here as System outprint hello world. We shall save it by clicking on File and save all. Now before running this code we need to check something. Click on the Run tab and then go to Edit Configuration. A window pops up and you will see few fields filled up there. The first one refers to the main class which is the same as the package name. You can see this on the left side of your screen as well. The next filled field is our working directory where the project has been saved. Next is class paths. Module It refers to the folder our main class is in. In this case we name our project folder as First Program which is already here. So this also looks cool. Last one refers to the JDK version you have installed. Most of the times IntelliJ takes up all this automatically, but if it doesn't, you need to change it. So always double check it before you run the code. Now when we press Run button here or Run Main from the Run tab we will see a new window pop up which shows our required text that we wanted to print. This window shows all the results of our code when we run it. If we give multiple print commands, all of them gets printed when we run the program in the order they are mentioned inside the main function. So I just ran the code here and did not compile it. The good news is that IntelliJ does that for me. It compiles the code before I run it. So if I change hello world to hello Java it will print. Hello Java. I just changed the code and did nothing else in Command line. I had to recompile it here. IntelliJ does that before I run it. IntelliJ is of immense help. It highlights the code which indicates the correctness in terms of syntax, suggests commands when you start typing and obviously allows you to change and run code really quick. Try to answer the question that follows.
IntelliJ can be downloaded for Mac and Windows in both the ultimate and community versions
Opening IntelliJ shows options for creating a project, importing a project, and opening a file
Projects are useful for organizing code, and a new project can be created with IntelliJ
IntelliJ asks for the Java SDK to be used, which can be automatically detected or manually selected
A template can be used to provide default code for the project
A project name, location, and package name can be specified, with defaults provided by IntelliJ
The main function and class contain all the code and can be found on the left side of the screen
The print command can be used to print "Hello World" in the main function
Configuration settings for the project, including the main class and working directory, can be accessed in the Run tab
IntelliJ compiles the code before running it, and the output is displayed in a pop-up window
IntelliJ highlights code for syntax correctness and suggests commands for faster coding.
So you now know how to create projects on IntelliJ. Also, you learnt how to write codes on the same platform. With a click on the Run button, your code is compiled and executed. Let’s now move on to learning about the language IntelliJ understands.