Hello friends, we discussed how to write our first basic Java code. We used Notepad as text editor. We also discussed how to compile, run and see the output of our Java code.
Today we are going to discuss IDE. In this video we are going to learn, how to use an IDE & it’s advantages. So lets get started. What is an IDE ? IDE stands for Integrated Development Environment.
It is a software application, in which many tools are bundled in a single platform. An IDE generally consists of a source code editor, compiler, interpreter & debugger. And many more features.
And all are bundled in a single package. In the last video, Notepad acted as source code editor. Then we used “javac” command to compile our Java code. “java” command was used to interpret our code. And after all those steps, our output was shown in the command prompt.
But to do that, we performed numerous steps which is not a standard procedure. But in case of IDE all those steps transformed in a single step. We perform all the operations such as code writing, compiling, interpreting, execution in a single platform. And just by pressing a single button all the processes get executed.
IDE contains some additional features which we cannot access in Notepad. If any error occurs while writing a code in Notepad. Notepad doesn’t identify that error. IDE also contains a debugger which is used to remove bugs from our code.
It also recommends us what to write, so as to remove error from our code. IDE also offer some external advantages like online code storage which is used to store our code into cloud.
Code optimiser is used to optimize our code, so as to make our code more efficient and fast. Formatter is used to format our code into a better human readable format. Also a number of plugins & extensions are available which helps us to create rich applications.
These all are the features of an IDE. Here I provided some examples of IDEs. Like Eclipse, Cloud9, C++ Builder, Intellij. Here I have written Android Studio. All the applications which are running in Android phones & tablets are created in Android Studio. In the same way, I have mention XCode.
It is also an IDE which is supported by Apple Inc. in which applications are developed which runs in iPhone, iPad, iPod, etc. So we have to select an IDE from this list.
For this course, I am going to work in Eclipse IDE. The main reason behind selecting this IDE is that it very popular & stable IDE for JAVA Development. And it is easy to use. Its a child’s play to work in IDE. Fro every operations, various buttons are provided.
And all we have to do is to press those buttons. I have provided a link to download the Eclipse IDE. You can find the links in the description of this video. You can access that link to download the IDE package.
Let me show you that link. When you open the provided link then it will look something like this. Here you can select your computer’s operating system like Windows, Macintosh, Linux. So you can download the package according to your computer’s operating system.
I am using Windows 64-bit operating system. And I have already downloaded the package for my computer. When your download is complete, then you can see a compressed file or Zip file. When we extract this file, a folder named as “eclipse” appears.
We open this folder and here we can see an application named as “eclipse” and we run it. As you can see our eclipse IDE is loading. Now we select a directory in which our project get saved. By default the project gets saved in your “Users” profile in the name of “eclipse-workspace”.
We can modify this directory by clicking on browse button and selecting the desired directory. For now we are going to use the default location and press the launch button. Here all the JDK files and packages get loaded into the IDE. And it shows a beautiful code editor.
Our workspace is loaded. Here we will be performing our coding skills. There are number of functions available but for now we are going to click on “Workbench”. We start writing our code in workbench. Here we can see an empty space. In the project explorer, we can view all the files & folders.
If you are getting confuse, then don’t worry I will help you & explain all the details of this IDE. For now , this is project explorer. And here we can view our files & folders. This is our code-editor.
Here we are going to write our code. And this is console in which our output is shown. So first, we go to File and click New and select Project.
Here IDE is asking what kind of project do we want to make. We are building a Java project so we select Java Project or we can type type & select Java Project. We only have to select Java Project.
Here we provide a name for our Java project “My First Project”. You can use any other name. And here we can select the version of our JRE. For now I am going to select the latest one. And then we click on finish.
We should always open perspective so as to introduce Java supported files in our project. Here in the project explorer we can click on this arrow button and we can see a folder named as “src”.
It is also known as source folder. In this folder we store all our classes and packages. And this folder is JRE system library which contains all the files which were provided by JDK.
We right click on “src” then select “New” & then we select & define “Package” Package is nothing but a folder in which our classes & supporting files are kept.
Here I provide a name for our package. Now see we can identify the usefulness of IDE. As soon as I enter a name for our package. It is showing that a package name will always starts from a lower case letter. It means all the names of packages starts from a lower case.
So let me correct it. Here we can see that I have written the first alphabet of the first letter in lowercase. And rest of the first letters are written in uppercase. This style is known as “Camel Casing”.
It is a standard & lexical design to write a Java code. By using this style our code looks more professional & elegant. So we finally click on finish. Here we have successfully created a package.
Now we right click on this package and select “New” & then select “class” We know that all Java codes are nothing but Java classes. So here we select class. In the previous video, I told you that your class name & your filename should be same and relevant.
For now I am putting our class name as “Example”. And then click on finish. Here we can see a file named as Example.java is created And this IDE already created a class whose name is Example. Here we can also view the name of package in which this class resides.
From this statement we can see that there is a package named as “myFirstPackage” which contains a class named as Example.java Here we can see that words are differentiated by using different colors. This is because of formatter.
Here “package”, “public”, “class” are known as Java Keywords. I’ll explain keywords in future videos. For now you can see how a formatter differentiates between words. Braces are also placed automatically. This is feature of IDE through which code editing becomes a simple task.
Now have to write a main function which acts as an entry point in our code. Main statement is “public static void main(String args[ ]);” As soon as we enter a wrong word or if I perform a typo, then IDE automatically notify me. Here it is telling us that we have typed a wrong spelling of “static”.
This kind of privileges are not available in Notepad, that’s why we use IDE instead of Notepad. Here we can write our print statement so as to write our data on the display. Print statement is “System.out.print(“Rajat”);” Here we can see it is showing an error.
This error occurs because we didn’t provide the double inverted commas in our print statement. So these are the features of an IDE which helps us to program more efficiently. It is performing a code check as soon as we write a single word in it.
Here let me put my name “Rajat”. And finally I can save this project by going to File and then click on Save. In the case of Notepad editor, after writing the code we enter javac command then java command. After that our code runs. Here we just have to click on this “Run” button & rest IDE take care of itself. And here we can see that our output which is my name, is printed on the console. Without any error.
If there was any error then that would appear in the “Problems” tab. Here it is showing zero which means no error. So this is how an IDE works. My main motive behind this video is to give you guys a glimpse of a working of a java code practically. Also by this video you guys can learn how an IDE works. All of our future videos will be based on this IDE. And we are going to practice a lot.