 In this video I'd like to give you a quick tour of Dr. Java. There are instructions on the website if you'd like to install this on your own machine, and we also have it available in the labs. So take a quick look at the toolbar, a quick look at the menu options. It's always good to explore a new program for the first time to get a sense of what's there. The first feature I'd like to show you today is how to create a new Java class. Now, in all of the menus you'll notice there are shortcut keys along the right-hand side for these options. So control-shift-n is the quick way to create a new class. I'm just going to use hello and show you the hello world program. One thing I like about this wizard is you can check the box there to include main method, and it will go ahead and type the code for the main method for you. Although you should memorize that line of code, you're going to need it for the rest of your life probably. You can also see it generates some comments automatically, so maybe I'll replace this the hello world program. And this other thing, add your code here, is actually a little bit misleading for beginners. In Java, when you want to create multiple methods, you add them here. But at least for the first month of the course, we're going to do everything in the main method. So I'm just going to go ahead and delete that comment and go ahead and fill in the code. System.out.printline. Hello world. Oops, there we go. Now, when I hit save, it automatically knows that the file name will be hello because that, in fact, is the name of the class. And I'll go ahead and save this on my desktop, which is where I was last using this program. I had some other examples earlier. So when I push save, I'll go ahead and show you my desktop. I have now hello.java there. That's the only file visible on the screen. Now, in order to run a Java program, you first have to compile it. So I'll hit the compile button here. And it says compilation completed. The following files are not compiled blank. Oh, well, I have this other file here entitled that I never used. Let me go ahead and close that. One thing to note is when you push the compile button in Dr. Java, it will compile every single file that you have open and also any files that they reference. So you're going to basically compile everything that you need as long as you have it open. Now that I've compiled the hello program, you'll notice I have a new file on my desktop, hello.class. And that is the byte code for the program that I just wrote. All right, now let me push the run button. And it says, welcome to Dr. Java. Working directory is such and such. So this is my desktop directory, which is where the file was. It automatically gave the command in interactions run hello, but that's what the run button does. You'll push that again. We'll do it again. Hello world. You can tell this is the output of the program because it's green. You can also click on console, and it shows you all of the output that you've done over time, right? So if I ran this program multiple times, it always resets this screen, and this console keeps a history of all the different trials I have done. And of course, the compiler output, if there's any warnings or messages, they will be under that tab there. I'd like to give you a little bit more information about this interactions window pane here because it's actually one of the best features of Dr. Java in terms of teaching. What you're able to do is basically write any sort of Java code. So for example, you'll remember in the book this week, we had system.out.print hello, exclamation point, new line character. How are you doing? Question mark, new line character. Now, if you just wanted to see what is the result of this code, you can type it directly into interactions, and it immediately runs that code. I didn't have to create a new class. I didn't have to save the file. I didn't have to compile the file and then run it. It's just a one-step trial and error. I can do another one from the book. This example, she said hello to me, and I'll just paste that in. I've got some examples open in another window here. And you can see how these backslash quote characters are escaped, and so it just prints out the normal quote character directly in the window there. But it's kind of nice. Again, I didn't have to create a whole file and then compile and run it just to see how that code works. I can interact with it directly in this interactions window. The other thing you can do, just like on the command line, is you can push up and down to get previous commands that you have run in that session. So if you want to try something and then tweak it a little bit, you can just push the up arrow and then edit and run it again until you get the result that you like. And then if you're programming, you can take that result, put it up into your code in the editor in the window above. One other thing you should know is that you don't have to write complete statements. So in the interactions pane, you can also just put any expression, like say the string here, and it will show you the result of that expression. So the string, hello backslash n, how are you doing today backslash n, is actually the string with these new line characters in it. I could type any sort of arithmetic, like 1 plus 2, and it tells me it's 3, and I'll save the rest for next week because there's some surprises with arithmetic there. Let me show you one more example. I'm going to push the new button here and bring in the badly formatted example from chapter one of the book. When I push save, again, it's going to know to call this file goodbye. So push save, and you'll see that I now have goodbye.java on my desktop. Now, one thing that you will do a lot is automatically format your code. There's no requirement in Java that code is indented correctly, but it just drives experienced developers, including myself, crazy to see code that looks like this. It's just really hard to wrap my mind around it and to see the structure quickly. One way to fix the formatting is to push control A, and I'll just show you that option in the menu. It's actually select all, right? But again, the shortcut keys are here on the right, and you should memorize the shortcut keys as you use them over time. After you've selected a region of text, you can press the tab key, and the tab key will automatically go through and reformat the file so it's indented correctly. This is especially important when you have blocks inside of blocks, right? So each part of code that's enclosed in braces is called a block of code, and to see that structure is really important for understanding the nature of the program. It also allows you and Dr. Java to click on a brace and it highlights the region that that brace stands for. So now I can go ahead and compile this file, which also, again, compiles the hello file because this compile button will just build everything that you have open. I'll push run, goodbye, cruel world, and that is the end of our video. We'll see you later.