 Hi everyone, we're going to go through A to Z of installing everything we need for Comp 1010 and writing our first program in both Eclipse and Visual Studio Code. And here with us is G who, I mean I'm G already, but we've got G on or Melody who's kindly helping us with this video. So the first thing we're going to do is we're going to search on Google or whatever search engine that you guys are using for Java SE download. SE stands for standard edition. It's the same as JDK or Java Development Kit. Can you go back one step please. Now, you'll see that there is a link for Java SE downloads Oracle technology because Java was brought over by Oracle from some micro system so we'll go there. And it's going to tell you that there is a link for the current version is 16.0.2 so we highly recommend that you download the latest version. There's a link for JDK download. That's Java Development Kit. It's the same as Java standard edition so while here it says Java SE Development Kit, they still haven't come up with an ambiguous terminology yet. So here, depending on your operating system, if you're on Mac use Mac OS installer, which is the DMG file and if you're on Windows. It's a 64-bit architecture or 32-bit architecture. It will probably tell you the right installer and we just use the 64-bit installer for our purpose. It will download the file. It's about 150 megabytes on a fast internet connection, probably 20 seconds on a slow one a minute maybe. Now, once that file is downloaded, we are going to double click on that and install it. It's on its way. No worries. I don't know that you can drag and drop partially downloaded files. Oh, I didn't know that too. Also be careful about what mirror you're downloading it from. It should be fine in this case. Okay. Anyway, give your admin rights and the installer will pop up. Here it says C drive slash program files slash Java slash JDK hyphen 16.0.2. Now that's the default part. And I suggest that you keep this part because Eclipse and Visual Studio Code often refer to this part. We go next. And it says successfully installed. And that's fine and close. We have Java standard edition. The next one is to install the integrated development environment, which is either Eclipse or Visual Studio Code. So again, we're going to go to our search engine and search for Eclipse IDE. And the first thing that comes up is eclipse dot org slash IDE. It has desktop IDs on the top right side. You'll see there is a download link with orange background. We click on that. And the latest version is Eclipse IDE 2021 hyphen 06. Now, it's important to download the latest eclipse IDE. The reason is because the latest IDE ships with JUnit 5.5 or 5.6, which we will need for our JUnit testing. So okay, you download that file. It asks for donations. Obviously you don't have to donate. And that file will be downloaded. Almost there. Okay, now Eclipse installer is there. So we're going to run that. Eclipse installer runs. There are a couple of packages that it gives you options for. We are going to use the first one which is Eclipse IDE for Java developers. Now here you will see. Now this is an important screen because it will ask you where Java resides. And you will also notice that it automatically has determined that Java is at C drive program files Java JDK hyphen 16.0.2. So that's what we're going to do. And it also tells you where do you want to install Eclipse, which is C drive slash user slash unknown blah blah blah. Okay, so software user agreement. You can read it. If you want, except install is pretty quick, takes less than 30 seconds to run completely. So now that your Eclipse ID for Java developers has been downloaded and installed, you can launch it. So all you need for writing Java programs is already there. And now we can proceed now here. The first time you choose a workspace, it's like a project area. And you can decide to have a dedicated workspace. So here it's chosen C drive slash user slash unknown slash Eclipse hyphen workspace that's the default workspace it chooses. If you're happy with that you can choose that and enable the button that says use this as default and do not ask again but G you can choose a different one if you want. We'll just leave it. That's fine and launch and don't ask again because otherwise every time it boots up it's going to ask you again. I promise won't be using this ID on Windows. Next one, you can see that on the top right side, there's a play button, and it says hide the welcome screen on the top right side. Yep, that's the one. And it takes you to eclipse nowadays they've already added a donate screen you can close the donate screen. It says donate cross. Yeah, that's it. So this is what you want your eclipse to look like. Now what we're going to do is we're going to create a new Java project. And it's quite intuitive. So you can see there's an option already create a Java project. We're going to name our project hello world now what he has already done very, very much correctly, he's, he's named it, starting with a lower case. There's no rule associated with that, but by convention project start with a lower case it also says, use the Exhibition environment jre Java se hyphen 16. And because it already did it's that that's the Java that resides on your computer and that should be used. But one thing that you should be doing is you should disable the box or uncheck the box that says create module info.java file. Click on finish directly. So it contains all project and inside that there is a jre system library folder. So it contains all the libraries which are in Java's standard library set, and that includes math and system and such libraries. It also contains a folder which is SRC. And that's a short form for source. So the source folder or the source code is in that. The source folder for SRC and create a new class. And this class should be named in upper cases. And it's again camel case. So if you say hello world, it starts with an uppercase edge. Now what he has done already he's, he's checked the box that says I would like to include the stub public static void main. You want to run a Java file. If you want the Java file to be an executable file, then you choose to include public static void main was parameter is a string array. The name of the array doesn't matter because it's a formal parameter you can change it as you want but check that if you want the program to run and finish the finish. And you'll see that eclipse does everything for you it creates the file structure. And it creates a public static void main before we proceed any further we'll do one more thing. We'll press control a. I don't even have to press control and press control plus. Sorry, I'm used to my vim controls. No control plus and control plus increases the font size. What we'll also do is some people like the dark mode better. So we're going to change the mode as well we go to window preferences. I'm sure it goes in appearance as well but at the very top general appearance, and you can see the theme can be changed from light to dark. And there's your dark theme. So you can change the theme as well. All right, I can see you really like when online number seven, which is inside our main function, we're going to write our code. So, first thing that we should do is we should add tabs so that the control is inside the main function so the indentation is correct. So you can see that G is already writing system dot out that print and in or print Ellen that's fine. Is that no so the out and print Ellen are in lower cases. You can write whatever you want. So let's see what our welcome message is. It's hello world backslash and now the backslash and is a new line character or a carriage return you don't need to include that because you've already used print Ellen. So the Ellen changes the line automatically. Oh, I will fix that. And we save this. Actually, instead of saving it, just run the program by using the play button which is on the top right side. I'm just going to quickly circle it. Perfect. Now, when you play it. Is this an option or a confirmation dialogue. Please make sure that you choose the box that says always save resources before launching. A lot of time students do that every single time throughout the semester and it's just a waste of time. You can see our our code shows up at the bottom. Now what I'm going to do is I'm going to request remote control from G, so that I can write a few lines of code inside this function. And I'll. Okay, so here, I've got my main function but I'm also going to write another function. I'm going to write a very simple function and let's call a public static. Int highest. Now this highest function accepts three integers. I'm going to name them a b and c. But when I expand on the left hand side in the package explorer you see that it says highest int comma int comma int. So in reality, that's the signature. Three integers Java doesn't see that it's a b and c Java sees that they are three integers. So the name of the variables is for our purpose only and I write this first of all we check if a is at least as big as both b and c if that's the case, we will return a immediately. Now, if the control reaches line number 16. Can you tell me what is guaranteed if we reach line number 16. It means that a is not at least more than both B and C, because if it were, we would have already returned the control. So it's between B and C, which means we can check if B is more than equal to see where it turned be. Similarly, what's guaranteed if the control reaches line number 23 that it can only be C. So we will return C unconditionally. So that's a really nice program to understand control flow. And now we will use this in our main function. We will create variables x equals 10 y equals 20 and Z equals 20 as well. We will then say, you need to finish the line line number 10. Thank you. You will see that because I didn't finish the line with a semicolon, I get this red cross sign indicating a compilation error, sorry, a compilation errors, we're going to move there and put a semicolon. Highest is now this is what we discourage having a variable which is the same name as functions, we're going to name this variable max equals, we'll call this function highest. I'll do something a little fun bit funky we'll say X plus Y, Y minus Z and Z times Y divide by X. There's a reason I'm doing this and it's to explain how actual parameters are passed into formal parameters. Finally, we are going to display our max value. First of all, let's run this program to see what the output is going to be or what we can do is we can try and do a manual trace X plus Y is 10 plus 20 which is 30. That's the value that's copied into a Y minus Z is 20 minus 20. So the value zero is copied into B and Z multiplied by Y divide by X is 20 multiplied by 20 divide by 10 so 20 times 20 is 400 divide by 10 is 40 40 is copied into C so we got 30 zero and 40. You will notice that 30 is more than equal to zero. Yes, but 30 is not more than equal to 40. So it's true and false, which is false. So it skips the conditional block goes to line 25. Zero is more than equal to 40 is false. So it skips the conditional block and goes to line number 31 and it gives returns the correct answer which is 41. Okay, 40. So when I run my program, you can see my output is 40. So this kind of understanding of controls flow where you can at least for simple programs, determine the output of the program is quite useful. And yes, that's our first program in Java what we'll also do is inside the Hello World package, we are going to create a new class. I'm going to print line and run this. Sorry, and include public static void main. And over here I'll just write this line. No worries, we can always fix these minor issues and print line and class spelling. Okay, so now when I run my program you can see that it's actually the file that's running. It's not necessarily the project that you're running, but the file that is in picture is running again I can double click on Hello World, and I can run that file instead. So that's how we use Java with eclipse I'm going to relinquish the control and give it back to Jay. And next we're going to try and do the same using which will studio code. Oh, I forgot to ask what if we wanted to get plugins, like a VIM plugin on eclipse. There is a VIM plugin for those of you who like using VIM so just Google for VIM plugin for eclipse and it can be freely done. It can be done easily but it's not in the domain of this video so we're going to move on to visual studio code. Dang it. We'll go to and on your search engine just search for Oh, wait, sorry. That's okay. Well, we can just crop this out. So you'll go to your search engine search for visual studio code. And it's code dot visual studio dot com. Download for windows. Okay, it's up, you can talk it's up fantastic so we can double click on visual studio code. File except the agreement and choose the path. It says okay whatever. And then the menu folders visual studio code if you want there's an option to not create it at the bottom left as well up to you. Next, add path which is good. And next, so basically just keep the standard options and it's fine. Is there anything else we did a download. No, there is an extension that will be downloading but that can be done from inside visual studio code. Also as a as a heavy price to pay for help for getting melodies help for this video I have to change my profile picture from messy to Leventoskey on island for the first week of the session. And so this is visual studio code. Now you'll see a cog wheel on the bottom left side. That's the one that you're going to click and choose extensions. On the top right on the top left side you see search extensions and search for Java extension back. And there is a start extension, you want to choose that and install it. Wait, okay. This isn't in the video but what about J unit. This is included in Java extension back earlier it used to be a different one but if you see the fourth fifth or sixth one from the top it says Java test runner. Let me annotate on your screen. So Java test runner. So that's the one for J unit testing. And that is a part of Java extension back now earlier it did it wasn't the case, but now it is. Okay. So that has been installed which is good. Now visual studio code processes Java project slightly differently from eclipse for visual studio code it's all about keeping things in the same folder. You'll see on the bottom, sorry, on the top left side, there is a folder icon. Just above that, yep, and we're going to open folder. And we're going to create a new folder if you want in here or inside desktop wait a second on the top left corner, you can see organize and new folder. Just to the right of organize there is new folder there. We're going to name it hello world again. And select that folder. I trust the authors. Yes, I trust the authors and close the welcome screen. Okay. Now, in us in here, you can add a new file so can you expand hello world as well. Okay. Slowly please expand hello world where it says drop down. Okay now keep it there. You'll see there are four options. Okay, so now the leftmost one is create a new file the second leftmost is create a new folder and refresh and whatever. The first one is new file we're going to create a new file. And we're going to name it with uppercase edge, because now please notice that file name doesn't have to be the same as the folder name so instead of hello world let's name it something different. Let's name it melody dot Java with an uppercase and again it's not disallowed but it's just convention that you start with an uppercase now this is the good part about visual studio code. I mean of course eclipse did everything for you from scratch when it generated the public class and inside that generate public static what may, but it's not too difficult in visual studio code either. Can you go there can you close the welcome panel. The right yep that's the one so you can see more okay now type in class or lower cases and you'll see the second option with the square and enter. And you can see that it generates public class melody automatically. Again here again what melody has done is he's moved one tap forward which is good and type main, correct, and you can see again there is an option for autocomplete, and can you get rid of this main and we'll do it slowly one more time. Okay, we tap forward and type main and we choose the option which has a square against it, which is the first one. It automatically generates public static what may inside that you can type whatever you want for system.out.println. I'm sure there's a I think there's a shortcut for that but I've never used it so I don't remember what it is. All right, so you've typed in a command and the command is good there is no red line there is no problem. I think the studio code has a slightly different way of indicating problems to talk about in a second but if you run the program now, and there's an option for run just above public static void main you can see it says run for debug. And there's also an option on the top right corner with that play button. So here it gives you a bit of junk. And then at the bottom line, it says hello world. I haven't been able to figure out a way to get rid of that whole verbatim output that it has. So if someone figures it out, please feel free to email me. Now what we do is we deliberately add a syntactical error by getting rid of that semicolon at the end of line six. What we'll also do is, can you go to that folder icon on the top left corner. Yep. Okay, now you'll see that melody to Java in open editors, the font color has changed to red. So let me annotate on that. You can see over here. It has changed to red font and that's indicating that there is a syntactical error in your program. So we're going to fix our program and add a semicolon at that at the end of that line. And save our program and you can see that now the font color has changed back to white indicating there is no error. On line number seven, let's add a variable declaration so create any variable of your choice and initialize it to a value if you want. Save it at that. And you'll see that the font color of melody dot Java has changed to yellow. So this indicates a warning, and the warning is that the variable is never being used. So warnings mean that your program will still run. It just means that there are some variables not being used or some functions not being called. That's it basically. So that's how you install Java Eclipse and Visual Studio Code. I mean play around with both Visual Studio Code and Eclipse and see which one you like better. There's another one. Netbeans. You can try that as well IntelliJ, NetBeans or JetBrains, whatever, you can try that as well. And yeah, stick to whatever you like. So that's how we install and set up our programming environment, including programming language and IDE. In another video, we're going to see how we import projects and how we write jail tests as well. Thank you very much. Thank you, G, for helping us with this.