1 00:00:00,270 --> 00:00:04,410 All right, we got our IDE installed and we're ready to start our first project. 2 00:00:04,410 --> 00:00:07,970 Projects can be thought of as what we were exploring each time we created a new 3 00:00:07,970 --> 00:00:09,240 work space. 4 00:00:09,240 --> 00:00:12,950 So for instance we would have started a new project for our Pez dispenser, one for 5 00:00:12,950 --> 00:00:15,900 our hangman game or one for our karaoke machine and 6 00:00:15,900 --> 00:00:17,470 what ever else we end up creating in the future. 7 00:00:18,590 --> 00:00:21,730 So let's dive in and explore how to create projects in your new environment. 8 00:00:23,200 --> 00:00:27,050 All right, so if it's not started up already, go ahead and start up IntelliJ. 9 00:00:27,050 --> 00:00:29,560 Then we'll click this Create New Project. 10 00:00:29,560 --> 00:00:34,420 Here you'll see it's asking for a Project SDK. 11 00:00:34,420 --> 00:00:37,600 Now SDK remember stands for software development kit. 12 00:00:37,600 --> 00:00:40,730 So let's choose the JDK we installed. 13 00:00:40,730 --> 00:00:44,710 Oh, it's not here, that's just common the first time you start up IntelliJ, 14 00:00:44,710 --> 00:00:45,650 the very first time. 15 00:00:45,650 --> 00:00:47,350 After we do this we won't need to do it again. 16 00:00:47,350 --> 00:00:49,530 So, I'm gonna click new over here and 17 00:00:49,530 --> 00:00:52,420 you'll see there's different types of SDK's that are available, and 18 00:00:52,420 --> 00:00:56,040 the one that we want is the JDK, or the java development kit. 19 00:00:56,040 --> 00:00:59,620 I'm gonna click that and of course this is gonna look different if you're on 20 00:00:59,620 --> 00:01:03,360 a different OS It's gonna try to guess where it's at and 21 00:01:03,360 --> 00:01:07,100 this on a Mac here will show what the directory structure looks like. 22 00:01:07,100 --> 00:01:09,930 So here we go, yeah this looks right it's in the library it's the JAVA. 23 00:01:09,930 --> 00:01:12,620 The one that I installed was JDK1.8. 24 00:01:12,620 --> 00:01:18,090 You might have installed a later version, okay, great. 25 00:01:18,090 --> 00:01:20,690 So I'm gonna go head and I'm just gonna click choose. 26 00:01:20,690 --> 00:01:23,210 Because it was correct, and there, sure enough there it is. 27 00:01:23,210 --> 00:01:26,220 So now we have this project SDK here, cool. 28 00:01:26,220 --> 00:01:27,100 So let's click next. 29 00:01:28,530 --> 00:01:31,344 All right, so in this oddly laid out window here, 30 00:01:31,344 --> 00:01:35,250 it's asking us if we wanna create a new project from a template. 31 00:01:35,250 --> 00:01:37,810 Now templates help by creating common code for us. 32 00:01:37,810 --> 00:01:41,020 For instance, the one template that we have available here is called 33 00:01:41,020 --> 00:01:43,020 the command line application. 34 00:01:43,020 --> 00:01:46,030 Also known as the console applications that we've been building. 35 00:01:46,030 --> 00:01:51,060 So, what this will do is it will write the boilerplate Java main method, and 36 00:01:51,060 --> 00:01:51,910 let's go ahead and do that. 37 00:01:51,910 --> 00:01:52,450 Let's choose that. 38 00:01:52,450 --> 00:01:55,720 So, I'm gonna click this, and it automatically chose that, and it says down 39 00:01:55,720 --> 00:01:58,340 here, Simple Java application that includes a class with the main method. 40 00:01:58,340 --> 00:01:59,870 That's exactly what we want. 41 00:01:59,870 --> 00:02:01,040 Great, so, let's choose that. 42 00:02:01,040 --> 00:02:01,680 We'll click Next. 43 00:02:03,100 --> 00:02:04,530 Okay, so let's name our project. 44 00:02:04,530 --> 00:02:08,090 For this first one let's just recreate that systemizer class that we wrote in 45 00:02:08,090 --> 00:02:09,310 the work space earlier. 46 00:02:09,310 --> 00:02:15,100 So, the name of this project would be Systemizer, cool. 47 00:02:15,100 --> 00:02:18,420 And see how it normally, it started going ahead and typing along and 48 00:02:18,420 --> 00:02:20,060 naming the folder the same as the project. 49 00:02:20,060 --> 00:02:23,380 That'll help us find it later so very similar on a Mac, 50 00:02:23,380 --> 00:02:27,450 this is my home directory, and then there's a folder called IdeaProjects. 51 00:02:27,450 --> 00:02:29,360 And whatever I named that is what it put here. 52 00:02:29,360 --> 00:02:32,490 I could make this different, but that's what I wanna have, I'm gonna leave it. 53 00:02:32,490 --> 00:02:35,740 And the base package, remember this is packages like we have been doing. 54 00:02:35,740 --> 00:02:38,958 So, you take your URL and flip it around. 55 00:02:38,958 --> 00:02:42,820 So we're com.teamtreehouse, if you have a website and 56 00:02:42,820 --> 00:02:44,430 you feel like putting it in there, feel free to do so. 57 00:02:44,430 --> 00:02:50,550 I'm gonna go ahead and click Finish and that's gonna build everything out for us. 58 00:02:50,550 --> 00:02:54,200 Okay, so these tips here, these are pretty awesome, but they're a little overwhelming 59 00:02:54,200 --> 00:02:56,640 and in your face, especially when you're just getting started. 60 00:02:56,640 --> 00:02:59,590 So what I'm gonna do is I'm gonna leave this check box, Show Tips on Startup, 61 00:02:59,590 --> 00:03:01,880 checked, but I'm gonna go ahead and close them. 62 00:03:01,880 --> 00:03:04,280 This is a great place to go, and you can click Next Tip and 63 00:03:04,280 --> 00:03:08,090 Previous Tip and kinda walk through and learn things about your IDE here. 64 00:03:08,090 --> 00:03:09,420 So I'm gonna go ahead and close it for now though. 65 00:03:10,480 --> 00:03:13,230 So before we get started I just wanted to let you know that I have a plugin 66 00:03:13,230 --> 00:03:15,950 installed that will show key commands as I'm using them, 67 00:03:15,950 --> 00:03:18,400 like keyboard shortcuts that I'm doing. 68 00:03:18,400 --> 00:03:20,890 And it will show both Mac and Windows. 69 00:03:20,890 --> 00:03:23,580 Now, the keyboards on Mac and Windows machines, 70 00:03:23,580 --> 00:03:25,900 if you don't know, are a little bit different and 71 00:03:25,900 --> 00:03:28,830 therefore the hotkeys that you do to do things are a little bit different. 72 00:03:28,830 --> 00:03:31,790 I just thought it'd be nice to show on the screen what's going on. 73 00:03:31,790 --> 00:03:35,120 You will not see those on your screen don't worry about that. 74 00:03:35,120 --> 00:03:38,320 So this area here is called the editor and it's where we're going to do editing and 75 00:03:38,320 --> 00:03:42,480 it works much like that editor we were using in workspace, but 76 00:03:42,480 --> 00:03:45,010 it is infinitely more powerful. 77 00:03:45,010 --> 00:03:49,100 Now since Java's a strongly type language, it knows things about what we're trying to 78 00:03:49,100 --> 00:03:52,250 do, through a process called code inspection. 79 00:03:52,250 --> 00:03:52,842 Here, check this out. 80 00:03:52,842 --> 00:03:57,230 I'm gonna start typing, and it's going to take a stab about what I'm talking about. 81 00:03:57,230 --> 00:03:58,360 This is called code completion. 82 00:03:58,360 --> 00:04:01,410 So, I'm gonna type S, and look at that. 83 00:04:01,410 --> 00:04:04,690 It popped up a list of what I could probably be talking about. 84 00:04:04,690 --> 00:04:08,430 So, I'm going to use the arrow keys and I'm going to choose System, 85 00:04:08,430 --> 00:04:10,370 because what I want to do here is I'm going to write out to the screen. 86 00:04:10,370 --> 00:04:12,390 Let's do System.out.println. 87 00:04:12,390 --> 00:04:18,570 So, I'm gonna choose System, I moved using the arrow keys and I'm gonna press dot. 88 00:04:18,570 --> 00:04:22,250 And there it chose that and because it knows what type of class this is, 89 00:04:22,250 --> 00:04:26,370 it knows what the public fields are and it also knows what all the methods are. 90 00:04:26,370 --> 00:04:28,130 So you can see all the methods that are available here. 91 00:04:28,130 --> 00:04:32,330 So I'm gonna go ahead and choose out and again I'm gonna press dot. 92 00:04:32,330 --> 00:04:36,890 And because it knows what type out it is it knows the different things that it 93 00:04:36,890 --> 00:04:40,610 can do so, if we stroll down here we can see that it has print, I can start typing 94 00:04:40,610 --> 00:04:45,060 as well and it will go down on the list of what's available and I wanna do println. 95 00:04:45,060 --> 00:04:47,990 So that's great let's go ahead and backup a bit I just want 96 00:04:47,990 --> 00:04:51,460 to show you what would happen if we move away so I'm gonna click my mouse away. 97 00:04:51,460 --> 00:04:53,490 Now you'll see that it highlighted in red and 98 00:04:53,490 --> 00:04:54,830 see that little red squiggly line here? 99 00:04:54,830 --> 00:05:00,610 Let's mouse over that and it says, that it can not resolve symbol 'pr'. 100 00:05:00,610 --> 00:05:05,040 And that also there's another error, that it expected a semi colon. 101 00:05:05,040 --> 00:05:06,238 Handy, right? 102 00:05:06,238 --> 00:05:08,740 So I'm gonna to go back and put my cursor right here and 103 00:05:08,740 --> 00:05:12,850 if I wanted to get the code completion to kick off again, I can press control space. 104 00:05:14,940 --> 00:05:15,510 Give that a second. 105 00:05:15,510 --> 00:05:18,080 The first time that this kicks off it has to index everything. 106 00:05:18,080 --> 00:05:20,150 So just give this one second and it'll be quicker in a bit. 107 00:05:21,460 --> 00:05:28,390 Again so we can choose println and we'll say hello from our IDE. 108 00:05:29,540 --> 00:05:35,270 Cool so I'm gonna go ahead and save and I did that with Apple S and 109 00:05:35,270 --> 00:05:37,940 because that's such a common thing to do right. 110 00:05:37,940 --> 00:05:42,270 If you're going to always be logging out to the screen, there's a shortcut to it. 111 00:05:42,270 --> 00:05:47,540 So if you type out S-O-U-T and actually see there's some other ones on here. 112 00:05:47,540 --> 00:05:51,270 But we're going to to S-O-U-T and I'm going to press the tab key and 113 00:05:51,270 --> 00:05:52,720 there's the System.out.println. 114 00:05:52,720 --> 00:05:55,340 There, lots of savings there. 115 00:05:59,054 --> 00:06:03,340 Okay so let's just go ahead and run this. 116 00:06:03,340 --> 00:06:07,750 Now remember what we had to do in the past was compile with the Java C program and 117 00:06:07,750 --> 00:06:09,810 then run the program with the Java command. 118 00:06:09,810 --> 00:06:12,530 Well guess what, this IDE knows how to do that. 119 00:06:12,530 --> 00:06:20,870 To run this code let's go to the Run menu, it's up here Run and chose run main. 120 00:06:20,870 --> 00:06:24,530 Note next to this instruction here there's a little keyboard shortcut here. 121 00:06:24,530 --> 00:06:27,850 So it's saying on a Mac if I do Ctrl + R it will run. 122 00:06:27,850 --> 00:06:31,630 Now because we created this project using the command line template 123 00:06:31,630 --> 00:06:34,380 everything was already all set up for us to just run this. 124 00:06:34,380 --> 00:06:36,610 We'll see later how to configure things this way but 125 00:06:36,610 --> 00:06:39,580 because the template was using main it automatically knows what that is so 126 00:06:39,580 --> 00:06:40,740 let's go ahead and let's run this. 127 00:06:41,970 --> 00:06:46,280 Okay so now things are being compiled and 128 00:06:46,280 --> 00:06:50,580 it ran and here in this area down here is our console. 129 00:06:50,580 --> 00:06:53,150 If you mouse over you can see the program that was actually run and 130 00:06:53,150 --> 00:06:55,340 you can see here that it says JAVA and 131 00:06:55,340 --> 00:06:59,480 then a bunch of parameters dropped we'll explore that a little bit later. 132 00:06:59,480 --> 00:07:03,750 So, you can see how the program ran. 133 00:07:03,750 --> 00:07:08,110 I clicked in and I'm just going to move my mouse, move my cursor over and 134 00:07:08,110 --> 00:07:11,470 we could see that I called all of these different properties. 135 00:07:11,470 --> 00:07:15,980 Wow, right, and there it's at the class path that was in the dash CP we did 136 00:07:15,980 --> 00:07:20,140 before, so it got the class path also, so I just wanted to show you that and 137 00:07:20,140 --> 00:07:21,060 that's how it's running it off. 138 00:07:21,060 --> 00:07:23,560 And here's our messages, hello from our IDE and saving space. 139 00:07:23,560 --> 00:07:25,540 Those are just the two things that I wrote there. 140 00:07:25,540 --> 00:07:30,585 Okay, so, let's go ahead, I'm going to remove these two lines and 141 00:07:30,585 --> 00:07:34,980 save again. 142 00:07:34,980 --> 00:07:37,890 Okay, so let's go grab the code that we wrote in workspace and 143 00:07:37,890 --> 00:07:38,810 just plop in in here. 144 00:07:38,810 --> 00:07:40,310 It's in the teacher's notes below. 145 00:07:40,310 --> 00:07:44,900 So, I came over to my workspace and I copied and I'm gonna come in here and 146 00:07:44,900 --> 00:07:46,420 I'm just gonna paste. 147 00:07:48,470 --> 00:07:53,842 All right, so let's move the cursor over here where 148 00:07:53,842 --> 00:07:58,860 it's highlighted in red, this thing set here. 149 00:07:58,860 --> 00:08:00,590 Let's see what it says. 150 00:08:00,590 --> 00:08:02,370 It's saying that it doesn't know what a set is, and 151 00:08:02,370 --> 00:08:04,710 I remember we didn't import that. 152 00:08:04,710 --> 00:08:05,740 So that's why it's saying that. 153 00:08:05,740 --> 00:08:08,370 So let's go ahead, I'm gonna press, and 154 00:08:08,370 --> 00:08:12,790 that key command there is Alt + Enter on a Mac that's what it's suggesting that I do. 155 00:08:12,790 --> 00:08:16,340 So I'm gonna go ahead, I'm gonna press that, okay. 156 00:08:16,340 --> 00:08:19,920 And here is the action that it's suggesting is to import the class, so 157 00:08:19,920 --> 00:08:22,450 let's go ahead and do that, cool. 158 00:08:22,450 --> 00:08:25,100 And then it's doing it again for the TreeSet, so I'm gonna do that again. 159 00:08:25,100 --> 00:08:28,810 I'm gonna press Alt+Enter, and it imported and if we scroll up, 160 00:08:28,810 --> 00:08:32,200 you'll see that it did the imports for us, pretty cool, right? 161 00:08:32,200 --> 00:08:36,340 Huh, it looks like there's still a problem so, 162 00:08:36,340 --> 00:08:38,640 look here I haven't let's mouse over here. 163 00:08:38,640 --> 00:08:40,650 It says class or interface on this one. 164 00:08:40,650 --> 00:08:45,520 I think I have an extra brace so if I move my cursor, see how it highlights this ones 165 00:08:45,520 --> 00:08:47,270 highlighted and that ones highlighted up there. 166 00:08:47,270 --> 00:08:50,310 And then if I go to this one that's closing the main class 167 00:08:50,310 --> 00:08:52,430 then this is closing nothing. 168 00:08:52,430 --> 00:08:55,390 So I have an extra brace, so I'm gonna go ahead and get rid of that, 169 00:08:55,390 --> 00:08:56,860 and now everything is happy. 170 00:08:56,860 --> 00:08:59,670 There we go, so I'm gonna save that. 171 00:08:59,670 --> 00:09:02,470 All right, so let's run that again. 172 00:09:02,470 --> 00:09:07,130 So again, that was Ctrl+R or Shift+F10 on Windows and Linux. 173 00:09:12,800 --> 00:09:14,720 Cool, awesome, here it is. 174 00:09:14,720 --> 00:09:16,720 It's a whole of different things. 175 00:09:16,720 --> 00:09:19,860 Okay so now one more thing that I wanted to show you really quick. 176 00:09:19,860 --> 00:09:22,870 Let's say that we were looking at this code that we wrote just a while ago, but 177 00:09:22,870 --> 00:09:24,590 let's say that we forgot what some of this was. 178 00:09:24,590 --> 00:09:26,980 So, if I wanted to highlight over this, and 179 00:09:26,980 --> 00:09:30,439 I wanted to see what this said, I could just press F1 for help. 180 00:09:31,750 --> 00:09:33,450 So here it is about the getProperties and 181 00:09:33,450 --> 00:09:36,100 it says that it returns the java.util.Properties and I can click that. 182 00:09:36,100 --> 00:09:38,870 And I can navigate just like we did to the documentation, but 183 00:09:38,870 --> 00:09:41,970 here it is, right in our code. 184 00:09:41,970 --> 00:09:43,120 Wow, right? 185 00:09:43,120 --> 00:09:45,800 What a powerful set of tools all ready, and there are so 186 00:09:45,800 --> 00:09:47,830 many more packed in there. 187 00:09:47,830 --> 00:09:51,230 I think a handy way to view this might be as a tool shed. 188 00:09:51,230 --> 00:09:54,320 There are lots of powerful tools in the tool shed that assist you in making 189 00:09:54,320 --> 00:09:55,700 tons of cool things. 190 00:09:55,700 --> 00:09:58,030 But they aren't used all the time. 191 00:09:58,030 --> 00:10:01,440 I mean you don't use the jigsaw every time you build something. 192 00:10:01,440 --> 00:10:03,740 Sometimes you just need a sander but 193 00:10:03,740 --> 00:10:06,280 when you do need that jigsaw it's good to know it's there. 194 00:10:07,480 --> 00:10:12,200 And like I mentioned, well, not all tool sheds have the same tools in them, more or 195 00:10:12,200 --> 00:10:16,580 less, the same tools are available in every heavily used tool shed. 196 00:10:16,580 --> 00:10:19,870 Eventually, every tool shed owner buys a nail gun 197 00:10:19,870 --> 00:10:21,750 just to stay competitive with their neighbors tool shed. 198 00:10:22,810 --> 00:10:26,190 I'm going to do my best at walking you through each of these different tools 199 00:10:26,190 --> 00:10:27,770 in your IDE tool shed. 200 00:10:27,770 --> 00:10:29,680 But I'm sure we won't touch on all of it. 201 00:10:29,680 --> 00:10:34,260 Feel free to explore, you'll not only learn about what the idea is capable of, 202 00:10:34,260 --> 00:10:37,550 but also some great Java best practices as well. 203 00:10:37,550 --> 00:10:39,920 And unlike the tool shed analogy I just used, 204 00:10:39,920 --> 00:10:42,930 you don't have to worry about losing a finger if you mess up. 205 00:10:42,930 --> 00:10:45,350 The help system at IntelliJ is really great and 206 00:10:45,350 --> 00:10:47,240 I wanna show you how to explore around. 207 00:10:47,240 --> 00:10:50,650 If you find some killer tool that you just love, share it in the forum. 208 00:10:50,650 --> 00:10:54,050 This stuff can be super exciting, and let's not let it overwhelm us. 209 00:10:54,050 --> 00:10:54,550 Sound good? 210 00:10:55,550 --> 00:10:57,500 I wanna show you how to deal with multiple files and 211 00:10:57,500 --> 00:10:59,690 importing other projects, right after this next exercise.