Beginning
First Steps For Windows Users
Setting up the Enviornment:
In order not to have any conflit during setup or excution of the IDE Intellij you'd better follow these instructions on the right order:
- Install the JDK ( Java Development Kit), you can download it from the following web page click here make sure you checked the agreement box before and chose the appropriate JDK for your OS.
- Then you can download and install the Intellij IDE, for that, please refer to the following web page
Now your environment is ready for use, so let's create our first program
Our First Java Program
After starting Intellij, click on Create New Project :
Next, click on Java project on the left side and don't select any additional libraries then click on Next:
and don't select any template just click on next:
and choose a project Name : "HelloWorld"
After that, expand the folder display "HelloWord" and right click upon src folder and click-> New-> Java Class: And choose a Name to your Java Class :
I suggest you to call it "MyHelloProgram". By the way, in java all the classes'names start with a capital letter. then the Intellij wizard will generate an empty class file,
with a class named MyHelloProgram as it is shown in the snapshot below
Now let's create a method inside the class MyHelloProgram, which we are going to call "main": this class will be public and static ( we are going to eplain later on the meaning
of these keywords):
After that, let's apply the following configuration upon Intellij in order to make it considering the "main method " as the principal method to be called during the compilation
and execution: for that go to the menu Run -> Edit Configurations
then the following popup menu will be opened -> go to the + button and choose the application option:
finally it becomes abvious to fill the form: on the top: enter the name of the main method which is: main then the name of the main class: MyHelloProgram then click on apply and ok.
In order to test our configuration and our program, Let's add the following portion of code which will print into the screen "Hello world!" as a result in the buttom of the IDE.
And in order to compile and execute click on the green play in the top of the IDE page which will compile and run our program: