1 00:00:10,029 --> 00:00:12,678 2 00:00:12,679 --> 00:00:15,948 This presentation is delivered by the Stanford Center for Professional 3 00:00:15,948 --> 00:00:22,948 Development. 4 00:00:25,618 --> 00:00:27,000 Any questions 5 00:00:27,000 --> 00:00:30,710 about anything we've done so far 6 00:00:30,710 --> 00:00:32,279 7 00:00:32,279 --> 00:00:35,650 before we dive into our next great topic? 8 00:00:35,649 --> 00:00:37,469 All right. 9 00:00:37,469 --> 00:00:40,490 One of the things that we've done the whole time in this class is we use these 10 00:00:40,490 --> 00:00:43,109 things called the ACM libraries. 11 00:00:43,109 --> 00:00:47,030 The ACM libraries are a set of libraries that are actually created by a 12 00:00:47,030 --> 00:00:50,060 task force of people. The ACM is the Association of Computing Machinery. We talked 13 00:00:50,060 --> 00:00:53,250 about them at the very beginning of the class when we talked about these libraries. 14 00:00:53,250 --> 00:00:56,509 They put together some nice libraries of stuff that are really useful for 15 00:00:56,509 --> 00:00:58,869 teaching, which is why we use them. 16 00:00:58,869 --> 00:01:02,239 Today, what I'm going to do is lift a little bit underneath the hood and talk 17 00:01:02,240 --> 00:01:04,540 about standard Java, 18 00:01:04,540 --> 00:01:07,540 which is what you would get if you didn't use the ACM libraries and 19 00:01:07,540 --> 00:01:10,659 you just used the standard Java libraries. Now, there's no reason why you can't 20 00:01:10,659 --> 00:01:12,920 continue to use the ACM libraries after this class. 21 00:01:12,920 --> 00:01:15,420 They're just another set of libraries that were written by a group of people that 22 00:01:15,420 --> 00:01:16,810 you're certainly welcome to use. 23 00:01:16,810 --> 00:01:18,769 So there's no reason why you 24 00:01:18,769 --> 00:01:20,019 should stop using them, 25 00:01:20,019 --> 00:01:23,129 but there were a couple important issues related 26 00:01:23,129 --> 00:01:26,318 to standard Java. Now it's 27 00:01:26,319 --> 00:01:28,299 time for you to know. 28 00:01:28,299 --> 00:01:34,890 So the first thing that's related to thinking about standard 29 00:01:34,890 --> 00:01:37,879 Java is when you're running your programs, when you go into Eclipse and 30 00:01:37,879 --> 00:01:41,280 you click on the little running guy to compile your programs. It give 31 00:01:41,280 --> 00:01:44,480 you a list of what 32 00:01:44,480 --> 00:01:47,740 classes you actually might want to run. If you only have one project, you 33 00:01:47,739 --> 00:01:49,469 may only get one choice, 34 00:01:49,469 --> 00:01:52,868 but one of the things you kind of think about is in the name surfer program, I 35 00:01:52,868 --> 00:01:55,328 actually have four or five different classes. 36 00:01:55,328 --> 00:01:59,029 How come it always knew which class to run? How come it always knew the name surfer class was 37 00:01:59,030 --> 00:02:01,099 the class that I actually should run? 38 00:02:01,099 --> 00:02:08,099 Anyone want to venture a guess? [Inaudible]. 39 00:02:08,699 --> 00:02:12,680 It's the only class with [inaudible] which is very related to 40 00:02:12,680 --> 00:02:16,019 an underlying issue. It's the only class that actually was 41 00:02:16,019 --> 00:02:17,449 extending programs. 42 00:02:17,449 --> 00:02:20,459 So one of the extended programs, what actually was happening in 43 00:02:20,459 --> 00:02:25,709 these ACM libraries is you were getting a method called 44 00:02:25,709 --> 00:02:29,930 main. Main is actually the place - you're old enough to see main. 45 00:02:29,930 --> 00:02:34,509 Main is actually the method at which Java classes actually start running. 46 00:02:34,508 --> 00:02:37,948 So one of the things you should think now, you 47 00:02:37,949 --> 00:02:39,950 never wrote a method called main. 48 00:02:39,949 --> 00:02:43,769 I never saw a method called main, and you're telling me that's where Java programs 49 00:02:43,770 --> 00:02:44,989 actually start running. 50 00:02:44,989 --> 00:02:46,479 Yeah, in fact it is. 51 00:02:46,479 --> 00:02:48,580 It's because programs 52 00:02:48,580 --> 00:02:52,049 provided this main method for you. What this main method did in the program 53 00:02:52,049 --> 00:02:55,370 was essentially get the rest of you program running by getting a few things 54 00:02:55,370 --> 00:02:57,489 set up and then kicking off your run method. 55 00:02:57,489 --> 00:02:59,618 So you didn't actually need to worry about this. 56 00:02:59,618 --> 00:03:01,288 But now you're sort of old enough 57 00:03:01,288 --> 00:03:05,228 to actually see what that main method is all about. 58 00:03:05,229 --> 00:03:08,649 So if we think about what this main method does, the header for the 59 00:03:08,649 --> 00:03:11,368 main method is also kind of weird. This is part of the reason why we never showed you 60 00:03:11,368 --> 00:03:12,659 the main method before. 61 00:03:12,659 --> 00:03:17,239 The header for the main method is actually public 62 00:03:17,239 --> 00:03:18,799 static 63 00:03:18,799 --> 00:03:20,429 void 64 00:03:20,429 --> 00:03:23,370 main, but we're not done yet. Main actually has some arguments. 65 00:03:23,370 --> 00:03:26,429 It has an array of strings 66 00:03:26,429 --> 00:03:27,539 called args 67 00:03:27,539 --> 00:03:31,938 and arguments, and then something in here happens inside of me. 68 00:03:31,938 --> 00:03:34,748 If we showed this to you on the first day, we would've had to go through and 69 00:03:34,748 --> 00:03:36,448 explain what all these words meant 70 00:03:36,449 --> 00:03:39,859 before we explained what main even was, before we explained how you 71 00:03:39,859 --> 00:03:41,050 write your first program. 72 00:03:41,050 --> 00:03:42,299 That would've been a pain. 73 00:03:42,299 --> 00:03:46,239 Now we can just tell you. Public mains is a public method. You know 74 00:03:46,239 --> 00:03:48,689 that. You probably recall the other public methods you've written. 75 00:03:48,689 --> 00:03:51,169 Static means that this is actually a 76 00:03:51,169 --> 00:03:53,539 method that belongs to the class 77 00:03:53,539 --> 00:03:57,179 - it's not something that you would actually call on a particular 78 00:03:57,180 --> 00:03:57,859 object. 79 00:03:57,859 --> 00:04:01,729 So you never have some object - like, here's my object X, and I call X 80 00:04:01,729 --> 00:04:02,490 .main. 81 00:04:02,490 --> 00:04:05,139 Main is just something that gets called. It's a 82 00:04:05,139 --> 00:04:08,778 class method as opposed to being a method that gets called on an instance. 83 00:04:08,778 --> 00:04:11,088 Void means it just returns nothing. 84 00:04:11,088 --> 00:04:14,579 What is getting passed in here is an array of strings. Where is 85 00:04:14,579 --> 00:04:18,709 that array of strings coming from? This actually harks back to 86 00:04:18,709 --> 00:04:21,899 when computers weren't all nice and graphical and everything. 87 00:04:21,899 --> 00:04:25,009 When people wrote programs, the wrote program and were 88 00:04:25,009 --> 00:04:27,949 typing on what's called a command line. They wrong the name of the program out. 89 00:04:27,949 --> 00:04:29,089 They actually typed it, 90 00:04:29,089 --> 00:04:32,279 and then they typed a bunch of things that they wanted to be passed into the 91 00:04:32,279 --> 00:04:32,978 program such 92 00:04:32,978 --> 00:04:35,938 as initial information to start that program. 93 00:04:35,939 --> 00:04:38,939 That was the initial thing, so if you had some program like name surfer, 94 00:04:38,939 --> 00:04:42,860 you might actually start off by giving the name of the program. 95 00:04:42,860 --> 00:04:45,499 Then after name surfer, you might give it 96 00:04:45,499 --> 00:04:47,369 the name of the data file, 97 00:04:47,369 --> 00:04:49,490 like data dot text. You 98 00:04:49,490 --> 00:04:53,218 might've given it some other things as well that were separated by spaces. 99 00:04:53,218 --> 00:04:57,509 This list of stuff is essentially what gets passed in here as arguments. 100 00:04:57,509 --> 00:04:59,020 They're strings, 101 00:04:59,019 --> 00:05:02,728 and this is how the program would actually know what came in on 102 00:05:02,728 --> 00:05:06,120 the command line when the program was kicked off. 103 00:05:06,120 --> 00:05:09,930 Java's not that old of a language. It sort of came around and 104 00:05:09,930 --> 00:05:12,459 gaining popularity in 1995. 105 00:05:12,459 --> 00:05:15,709 People weren't doing a lot of this in 1995. I already had my 106 00:05:15,709 --> 00:05:18,978 mouse and my folders and all this other stuff, 107 00:05:18,978 --> 00:05:20,689 even if you were six years old. 108 00:05:20,689 --> 00:05:24,319 You probably did. You're like, I never typed this stuff, 109 00:05:24,319 --> 00:05:27,889 so why do I care about it? The reason why Java's derived 110 00:05:27,889 --> 00:05:30,199 from another language called C, 111 00:05:30,199 --> 00:05:32,469 and there's a variation called C++ 112 00:05:32,470 --> 00:05:36,180 that was created when people were writing programs in the days of yore. The 113 00:05:36,180 --> 00:05:40,430 whole notion of main and having some arguments to get passed to main kind of 114 00:05:40,430 --> 00:05:42,879 came along with the baggage of 115 00:05:42,879 --> 00:05:47,060 actually having a program language that matches the same 116 00:05:47,060 --> 00:05:50,038 style programming languages when they did do this. 117 00:05:50,038 --> 00:05:52,848 So a lot of the times in real Java programs these days, there aren't really 118 00:05:52,848 --> 00:05:56,509 any arguments. If there are arguments, there's some system parameters or something like that. 119 00:05:56,509 --> 00:05:58,188 We don't usually worry about them. 120 00:05:58,189 --> 00:05:59,159 So 121 00:05:59,158 --> 00:06:02,038 when you go and look at some other Java program that isn't using the ACM 122 00:06:02,038 --> 00:06:04,639 libraries and you see this main thing, and you're wondering what it's all about, 123 00:06:04,639 --> 00:06:07,189 you can think of main analogously to run. 124 00:06:07,189 --> 00:06:10,169 It's just where the whole time you've been thinking of run as where 125 00:06:10,168 --> 00:06:11,698 you're execution starts, 126 00:06:11,699 --> 00:06:15,460 main is really where execution 127 00:06:15,459 --> 00:06:16,560 started. If you think about 128 00:06:16,560 --> 00:06:21,019 execution actually started in main, so how did this thing actually kick off 129 00:06:21,019 --> 00:06:22,818 my run method? 130 00:06:22,819 --> 00:06:24,848 Now you're sort of old enough to see that, too. 131 00:06:24,848 --> 00:06:28,459 So what it actually did - let's say this was the main method is something 132 00:06:28,459 --> 00:06:29,258 like 133 00:06:29,259 --> 00:06:30,199 name surfer. 134 00:06:30,199 --> 00:06:31,968 So somewhere 135 00:06:31,968 --> 00:06:35,769 inside of a program, inside of the ACM libraries for program, we had 136 00:06:35,769 --> 00:06:36,959 this main method 137 00:06:36,959 --> 00:06:40,969 that figured out what the name of your class was. Essentially, it had a one-liner in 138 00:06:40,970 --> 00:06:41,430 it 139 00:06:41,430 --> 00:06:44,028 that would've been equivalent to this. 140 00:06:44,028 --> 00:06:48,550 New name surfer 141 00:06:48,550 --> 00:06:51,169 142 00:06:51,168 --> 00:06:53,368 dot 143 00:06:53,369 --> 00:06:55,069 start cards. So it's a one liner. 144 00:06:55,069 --> 00:06:56,280 Now 145 00:06:56,279 --> 00:06:59,388 you know what this means. What was it actually doing? When 146 00:06:59,389 --> 00:07:01,059 main started, no 147 00:07:01,059 --> 00:07:03,699 objects exist in the world. It's a static method. 148 00:07:03,699 --> 00:07:07,520 So there's no object that you're giving the main message to. 149 00:07:07,519 --> 00:07:11,688 Main just wakes up and says, hey, I'm main. What am I going to do? 150 00:07:11,689 --> 00:07:13,310 Why don't I create 151 00:07:13,310 --> 00:07:17,790 some object of this particular type, name surfer, which happens to 152 00:07:17,790 --> 00:07:20,169 scan an object, which is your program. 153 00:07:20,168 --> 00:07:24,299 Remember your program, as we kind of talked about, implements the run method, and 154 00:07:24,300 --> 00:07:26,419 actually a program underneath the hood 155 00:07:26,418 --> 00:07:29,609 implements the runable interface that we talked about last time, with 156 00:07:29,610 --> 00:07:32,009 threads. We talked about the runable interface. 157 00:07:32,009 --> 00:07:35,199 All programs implement the runable interface. How do you kick off something 158 00:07:35,199 --> 00:07:37,699 that's runable? You say start. 159 00:07:37,699 --> 00:07:42,620 So what it basically did was created and object of your class, which was name 160 00:07:42,620 --> 00:07:43,170 surfer, 161 00:07:43,170 --> 00:07:47,229 and told it to start. It happened to start pass along these arguments, 162 00:07:47,228 --> 00:07:50,188 but you never needed to see those arguments. As a matter of fact, you never did 163 00:07:50,189 --> 00:07:51,439 see them because 164 00:07:51,439 --> 00:07:54,949 when your object was in stand shaded, it didn't expect any arguments. 165 00:07:54,949 --> 00:07:58,759 So the arguments actually got passed to this thing called start, which just ignored them, 166 00:07:58,759 --> 00:07:59,399 basically, 167 00:07:59,399 --> 00:08:02,959 and then started your run methods to kick everything off. 168 00:08:02,959 --> 00:08:06,129 Last time when we talked about start, we talked about this in the context of 169 00:08:06,129 --> 00:08:08,539 threads. So we said, oh, you create a new thread, 170 00:08:08,538 --> 00:08:11,269 and the object that's you're going to start running, we put inside a 171 00:08:11,269 --> 00:08:13,308 thread. We kick the thread off with start. 172 00:08:13,309 --> 00:08:15,720 In this case, we're not actually creating a new thread. 173 00:08:15,720 --> 00:08:19,539 We're just saying we want to start executing this object I just 174 00:08:19,538 --> 00:08:22,370 created. It implements runable, so you'll start running from the method 175 00:08:22,370 --> 00:08:22,860 run, 176 00:08:22,860 --> 00:08:26,600 but I'm not creating it in thread. So this thing is going to execute in the 177 00:08:26,600 --> 00:08:28,639 same thread of execution 178 00:08:28,639 --> 00:08:31,379 as the entire class. 179 00:08:31,379 --> 00:08:34,620 So I don't suddenly kick off something that's running in parallel with this guy. 180 00:08:34,620 --> 00:08:37,389 It's actually going to sequentially start name surfer, 181 00:08:37,389 --> 00:08:41,940 and that's the last thing this guy does. Run your whole program. Any 182 00:08:41,940 --> 00:08:43,370 questions about that? 183 00:08:43,370 --> 00:08:46,250 Kind of a funky concept, but that's basically what's going on. You should see 184 00:08:46,250 --> 00:08:46,769 it. We 185 00:08:46,769 --> 00:08:49,869 were creating an instance of your program and then just kicking it off. 186 00:08:49,869 --> 00:08:52,668 That's why, this whole time, we had this thing called the run method that 187 00:08:52,668 --> 00:08:53,759 had to be public 188 00:08:53,759 --> 00:08:57,779 because it was implementing the runable interface. But now you've seen 189 00:08:57,779 --> 00:09:00,740 main. We could've just 190 00:09:00,740 --> 00:09:03,649 had main in your program to begin with and included all this code. The only 191 00:09:03,649 --> 00:09:05,379 reason we didn't put it in there before 192 00:09:05,379 --> 00:09:08,070 is because we didn't want to explain any of this stuff. 193 00:09:08,070 --> 00:09:11,780 In week two of the class, right after [inaudible] all holding 194 00:09:11,779 --> 00:09:12,798 hands and singing 195 00:09:12,798 --> 00:09:15,509 Kum Ba Ya. We're like, oh, it's [inaudible] the robot. Let's give Java, 196 00:09:15,509 --> 00:09:18,279 public static void main. Straightening args. You're like, 197 00:09:18,279 --> 00:09:21,098 what is going on? We hadn't done arrays. We 198 00:09:21,099 --> 00:09:22,619 hadn't done classes worrying 199 00:09:22,619 --> 00:09:27,230 about static. We certainly hadn't done methods. We hadn't even done parameter passing. 200 00:09:27,230 --> 00:09:32,600 So we just waited until the end. Now you see it. 201 00:09:32,600 --> 00:09:34,399 Now that we have that idea, 202 00:09:34,399 --> 00:09:37,829 now we can think about, okay, if this is kind of what the standard Java world is, 203 00:09:37,830 --> 00:09:41,800 let me think about taking this idea and using it to help me take my existing 204 00:09:41,799 --> 00:09:45,399 programs that I've written and pack them up into a form so I can share them with 205 00:09:45,399 --> 00:09:46,959 family and friends. 206 00:09:46,960 --> 00:09:49,210 So that's what we're going to do next. 207 00:09:49,210 --> 00:09:55,360 The basic concept of doing this is something that's called a jar file. 208 00:09:55,360 --> 00:09:58,690 You've actually seen jar files before because you've been working with 209 00:09:58,690 --> 00:10:01,780 something this whole time in your projects 210 00:10:01,779 --> 00:10:03,919 called ACM dot jar. 211 00:10:03,919 --> 00:10:05,828 This was just a jar file 212 00:10:05,828 --> 00:10:08,138 that contained all the ACM libraries. 213 00:10:08,139 --> 00:10:11,178 Basically, all a jar file is, where does it get its name. It's not 214 00:10:11,178 --> 00:10:13,949 a big mason jar, although you can think of it like that. 215 00:10:13,950 --> 00:10:16,770 It stands for Java 216 00:10:16,769 --> 00:10:19,139 archive. 217 00:10:19,139 --> 00:10:21,199 That's where the name comes 218 00:10:21,200 --> 00:10:24,180 from. The basic idea behind the jar file is this can contain a whole bunch of 219 00:10:24,179 --> 00:10:28,449 different stuff. Most of the time, what it contains, is a bunch of classes in Java. 220 00:10:28,450 --> 00:10:31,750 You can think of this as the complied version of the classes. 221 00:10:31,750 --> 00:10:35,589 You can actually put source code inside the jar if you want, but most of the time 222 00:10:35,589 --> 00:10:36,600 when you get a jar, 223 00:10:36,600 --> 00:10:39,570 it doesn't have the source code associated with it. I just has the actual 224 00:10:39,570 --> 00:10:42,480 dot class files, which are the compiled version of the files. 225 00:10:42,480 --> 00:10:44,789 So you could put source files in here if you wanted. 226 00:10:44,789 --> 00:10:47,839 You could put data files in here if you wanted. You could put a bunch of things in here if 227 00:10:47,840 --> 00:10:48,408 you want, 228 00:10:48,408 --> 00:10:52,159 but we're really going to focus on the case of putting classes in here. 229 00:10:52,159 --> 00:10:55,289 So one of these already existed for you. It was ACM dot jar, 230 00:10:55,289 --> 00:10:58,469 and we're going to figure out how to actually create some of these ourselves 231 00:10:58,470 --> 00:11:01,019 and use them because you can actually think of them as something that's 232 00:11:01,019 --> 00:11:02,210 233 00:11:02,210 --> 00:11:05,210 executable. 234 00:11:05,210 --> 00:11:07,210 So if we come to the computer, 235 00:11:07,210 --> 00:11:09,050 here's name surfer. 236 00:11:09,049 --> 00:11:11,889 This is an actual working version of name surfer, so I'm not going to show you 237 00:11:11,889 --> 00:11:14,980 the rest of the files in case you're taking 238 00:11:14,980 --> 00:11:18,629 [inaudible]. All the code's in here, so the first thing I did in the name surfer program 239 00:11:18,629 --> 00:11:22,730 is I thought about, hey, I want to think of this in the standard Java world now, even 240 00:11:22,730 --> 00:11:25,589 though you're still using the ACM libraries. 241 00:11:25,589 --> 00:11:29,470 When I want to build this jar, I want to build it in a way that sort of makes it 242 00:11:29,470 --> 00:11:32,540 maximally portable. I can give it to someone who's over here on this PC and someone who's 243 00:11:32,539 --> 00:11:33,998 over here on this 244 00:11:33,999 --> 00:11:36,589 Mac. They don't need to have a Eclipse or anything like that. They can just run it. That's 245 00:11:36,589 --> 00:11:37,890 the whole point. 246 00:11:37,889 --> 00:11:39,669 So the first thing I'm going to do 247 00:11:39,669 --> 00:11:42,719 is to introduce my friend, the main method. 248 00:11:42,720 --> 00:11:46,389 So basically I put in the code you just saw. I add a method, public 249 00:11:46,389 --> 00:11:50,909 static void main has this array of strings called args that sets the parameters. 250 00:11:50,909 --> 00:11:53,509 That's just the way main is always defined to be. 251 00:11:53,509 --> 00:11:56,769 What it's going to do is create a new name surfer object 252 00:11:56,769 --> 00:11:58,379 and kick it off. 253 00:11:58,379 --> 00:12:01,840 That's the only thing I need to add to my program. So anywhere you had some 254 00:12:01,840 --> 00:12:03,089 class that 255 00:12:03,089 --> 00:12:04,049 extended program, 256 00:12:04,048 --> 00:12:06,649 you would add these three lines of code 257 00:12:06,649 --> 00:12:10,779 to get it compliant with standard Java. 258 00:12:10,779 --> 00:12:14,000 Once we do that, we need to create the jar file, which is the 259 00:12:14,000 --> 00:12:17,750 thing we're actually going to be able to execute. 260 00:12:17,750 --> 00:12:21,159 One thing you might be saying to yourself is that the 261 00:12:21,159 --> 00:12:24,480 ACM libraries already provide this. So why am I putting it 262 00:12:24,480 --> 00:12:28,560 explicitly in there? As a matter of fact, it's not super required that it be in there. 263 00:12:28,559 --> 00:12:29,199 264 00:12:29,200 --> 00:12:32,960 The real reason why we put it in there is to try and maximize 265 00:12:32,960 --> 00:12:35,940 portability. Even though Java's supposed to have this property 266 00:12:35,940 --> 00:12:39,430 where we write the Java code once and it can run on PCs and it can run on Macs and 267 00:12:39,429 --> 00:12:43,729 it can run on Vista and Tiger and all this other stuff, 268 00:12:43,730 --> 00:12:47,839 in reality, there's some little differences between these operating systems. 269 00:12:47,839 --> 00:12:50,939 So little problems creep up here than there, every once in a while. You actually 270 00:12:50,938 --> 00:12:53,068 saw a few of those in class on occasion. 271 00:12:53,068 --> 00:12:56,079 Some of you experienced them in the Lair. 272 00:12:56,080 --> 00:12:59,920 By putting in this line explicitly rather than kind of relying on the code that's in the ACM 273 00:12:59,919 --> 00:13:03,569 libraries, this is actually doing a bunch more complicated stuff. 274 00:13:03,570 --> 00:13:07,110 It needs to infer what the name of your class was. You never told it 275 00:13:07,110 --> 00:13:08,749 explicitly, hey, ACM library, 276 00:13:08,749 --> 00:13:12,469 I need a new one of these guys. Java has a facility called 277 00:13:12,469 --> 00:13:13,959 reflection where it can go and say, 278 00:13:13,958 --> 00:13:17,528 oh, let me take a moment to reflect. I'm going to go and look at the names of 279 00:13:17,528 --> 00:13:19,059 your classes 280 00:13:19,059 --> 00:13:22,419 and then do something to actually generate some code based on the names of your 281 00:13:22,419 --> 00:13:24,370 classes, which is what it was doing. But 282 00:13:24,370 --> 00:13:27,860 that kind of stuff can get a little bit frosty, so we're just going to say, hey, ACM, 283 00:13:27,860 --> 00:13:30,919 don't worry about it. I'm just giving it to you. I'm a nice guy. 284 00:13:30,919 --> 00:13:35,919 So just put it in to make it explicit. It maximizes portability is the main reason we put it in. 285 00:13:35,919 --> 00:13:39,779 So how do we create the jar file? What we're going to do - these 286 00:13:39,779 --> 00:13:42,429 steps are all in excruciating detail in your handout, so you don't need to worry 287 00:13:42,429 --> 00:13:46,000 about scribbling down notes quickly. What we're going to do is you first click - 288 00:13:46,000 --> 00:13:48,230 that's the most difficult part of the whole thing. 289 00:13:48,230 --> 00:13:53,050 You select the project that you want to create the jar file from. So name 290 00:13:53,049 --> 00:13:56,349 surfer. Then we go to the file menu, and we pick export. 291 00:13:56,350 --> 00:13:59,120 So this whole time you were doing imports when you were bringing stuff in, now 292 00:13:59,120 --> 00:14:01,340 it's finally time to give something back in the form 293 00:14:01,340 --> 00:14:02,629 of an export. 294 00:14:02,629 --> 00:14:04,740 So what you want to do when you click export is 295 00:14:04,740 --> 00:14:07,560 it brings up a little dialogue box. Sometimes this is closed. Sometimes 296 00:14:07,559 --> 00:14:10,609 it's open. It's not a big deal if it's closed. Open 297 00:14:10,610 --> 00:14:13,899 it. Inside Java, you click on jar file. That's what you want to create. It has 298 00:14:13,899 --> 00:14:17,679 this nice little jar icon there to remind you it's a 299 00:14:17,679 --> 00:14:20,109 jar file. You click next. I'm just going to take you through all the steps. 300 00:14:20,110 --> 00:14:23,480 We need to specify a couple things here. First we need to specify what's in the jar 301 00:14:23,480 --> 00:14:26,889 file. So I'm going to open up name surfer, and what I'm going to put inside the jar file - 302 00:14:26,889 --> 00:14:30,120 I don't want to have all of name surfer in the jar file. In terms of 303 00:14:30,120 --> 00:14:33,379 if you throw everything in there including this stuff called dot project and 304 00:14:33,379 --> 00:14:34,548 dot class pass, 305 00:14:34,548 --> 00:14:37,438 it actually gets a little bit confused. Some of those things are not germane 306 00:14:37,438 --> 00:14:40,269 to what we want to pack up in our jar. They're just kind of other 307 00:14:40,269 --> 00:14:43,210 administrative information. What we really want to have is everything 308 00:14:43,210 --> 00:14:44,830 inside the default package. 309 00:14:44,830 --> 00:14:47,850 So I just click on default package. I can double click on this to make sure that 310 00:14:47,850 --> 00:14:50,430 all of my Java files were checked. 311 00:14:50,429 --> 00:14:54,239 That's what I want in my jar. I want basically all of my Java files or the 312 00:14:54,240 --> 00:14:56,610 compiled version of all of my 313 00:14:56,610 --> 00:14:57,659 Java files. 314 00:14:57,659 --> 00:15:01,100 I make sure that this is clicked. It's clicked by default. Just make export 315 00:15:01,100 --> 00:15:03,009 generated class files and resources. 316 00:15:03,009 --> 00:15:06,709 So what it's going to do is compile those Java files into their corresponding 317 00:15:06,708 --> 00:15:07,438 class files. 318 00:15:07,438 --> 00:15:09,169 That's what it's going to put in the jar. 319 00:15:09,169 --> 00:15:13,189 There are other options, like I can export the Java source files if I wanted 320 00:15:13,190 --> 00:15:15,290 to. Then I give someone the actual source code. 321 00:15:15,289 --> 00:15:17,769 Most of the time, you don't want to do this if you don't want peoples 322 00:15:17,769 --> 00:15:20,578 sniffing through your source code. You're like, here, take the compiled - the ACM 323 00:15:20,578 --> 00:15:23,899 libraries, we're not going to give you the source code. Just take the ACM libraries. They're good 324 00:15:23,899 --> 00:15:26,559 for you. 325 00:15:26,559 --> 00:15:28,349 So once we have this, 326 00:15:28,350 --> 00:15:32,860 we need to specify where we want to save this jar file. So that's what 327 00:15:32,860 --> 00:15:36,379 select export destination. They should've just said, 328 00:15:36,379 --> 00:15:38,049 where do you want to save it. 329 00:15:38,049 --> 00:15:41,429 That's the export destination. We can browse around. 330 00:15:41,429 --> 00:15:44,629 Basically, I've already created a folder that has all my 331 00:15:44,629 --> 00:15:46,360 name surfer code in it over here. 332 00:15:46,360 --> 00:15:49,550 I'm going to save the jar file in that same folder. So this is just in the same 333 00:15:49,549 --> 00:15:53,028 folder for my project called name surfer that has all of my class files in it. 334 00:15:53,028 --> 00:15:55,958 You can put it wherever you want, just don't forget. That's kind 335 00:15:55,958 --> 00:15:56,739 of the key. 336 00:15:56,740 --> 00:15:59,560 Ifm going to save 337 00:15:59,559 --> 00:16:02,239 it here. You don't need to worry about the options down here. 338 00:16:02,240 --> 00:16:03,209 339 00:16:03,208 --> 00:16:06,359 They're just fine in the defaults that they're at. You click next. 340 00:16:06,360 --> 00:16:08,709 Then you come to the screen that seems like, 341 00:16:08,708 --> 00:16:12,729 what's going on. Export files with compile warnings. Yeah, we just 342 00:16:12,730 --> 00:16:14,850 want to export everything. So we just 343 00:16:14,850 --> 00:16:16,540 click 344 00:16:16,539 --> 00:16:20,589 next. This is the most interesting part of the whole thing. 345 00:16:20,590 --> 00:16:24,100 What we want to do when we actually create this jar file, and this is 346 00:16:24,100 --> 00:16:28,019 something we only need to do when we have other jar files like the ACM libraries, 347 00:16:28,019 --> 00:16:29,399 we need to 348 00:16:29,399 --> 00:16:32,879 generate a manifest file. 349 00:16:32,879 --> 00:16:37,460 Basically, all a manifest file is, it's a complicated name. It 350 00:16:37,460 --> 00:16:39,860 sort of sounds formal. It sounds like they're on a 351 00:16:39,860 --> 00:16:42,720 boat, and they're like, oh, where's the 352 00:16:42,720 --> 00:16:43,790 passenger manifest? Really, all a manifest is - I'll 353 00:16:43,789 --> 00:16:47,029 show you the manifest file. It's two lines long, and then 354 00:16:47,029 --> 00:16:50,279 you add one line to it. 355 00:16:50,279 --> 00:16:53,959 It's basically just a little bit of administrative information that's kept 356 00:16:53,960 --> 00:16:55,230 around with your jar file 357 00:16:55,230 --> 00:16:58,840 so it knows what kind of stuff you're using with this jar file. That's 358 00:16:58,840 --> 00:16:59,579 all it is. 359 00:16:59,578 --> 00:17:03,058 So what we want to do is generate the manifest file. Make sure you save the 360 00:17:03,058 --> 00:17:06,038 manifest in the workspace is checked, which it should be. 361 00:17:06,038 --> 00:17:06,689 362 00:17:06,689 --> 00:17:10,279 Then you need to specify where you want to save the manifest file. 363 00:17:10,279 --> 00:17:13,279 The place I want to save it is basically in the same folder for my name 364 00:17:13,279 --> 00:17:16,558 surfer project in the name manifest. You could 365 00:17:16,558 --> 00:17:17,719 browse around if you wanted to, 366 00:17:17,719 --> 00:17:20,749 but usually the name you give it is the name of the folder that all your project 367 00:17:20,749 --> 00:17:24,798 stuff's in, and then the name manifest, which is going to be the actual name of the 368 00:17:24,798 --> 00:17:26,408 file. Any questions about that? 369 00:17:26,409 --> 00:17:27,300 Manifest file? 370 00:17:27,299 --> 00:17:30,200 The other thing you need to do when you're specifying a jar is a jar's just 371 00:17:30,200 --> 00:17:31,930 a bunch of classes. 372 00:17:31,930 --> 00:17:34,409 It needs to know in some sense 373 00:17:34,409 --> 00:17:37,309 if someone ends up running this jar - you'll see that in just a 374 00:17:37,308 --> 00:17:38,899 second. You can run a jar - 375 00:17:38,900 --> 00:17:41,560 where should it start? Which class 376 00:17:41,559 --> 00:17:44,019 should I call its main 377 00:17:44,019 --> 00:17:48,180 method. That's what you specify here. Select the class of the application entry 378 00:17:48,180 --> 00:17:48,910 point. 379 00:17:48,910 --> 00:17:51,470 It's kind of a very formal way of saying, 380 00:17:51,470 --> 00:17:53,860 where should I start running? 381 00:17:53,859 --> 00:17:57,748 So the place I want to start running, it lists to you all the classes 382 00:17:57,749 --> 00:18:01,079 that have a main method. Those are all the ones that can start running. 383 00:18:01,079 --> 00:18:05,048 Name surfer is the only one. So I click okay. So it says the main class is name surfer. 384 00:18:05,048 --> 00:18:09,299 Now there's no more next buttons. Now all I can do is click finish, 385 00:18:09,299 --> 00:18:13,639 and I just created a jar 386 00:18:13,640 --> 00:18:16,650 file. You're like, oh, [inaudible] double click. Double click. 387 00:18:16,650 --> 00:18:18,100 We're not there yet. 388 00:18:18,099 --> 00:18:21,429 There's two things that you'll notice if you look over here in the 389 00:18:21,430 --> 00:18:22,509 package explorer. 390 00:18:22,509 --> 00:18:25,829 You'll notice now we have something called a manifest file because that's where I 391 00:18:25,829 --> 00:18:26,388 saved it. 392 00:18:26,388 --> 00:18:30,368 I also have name surfer dot jar, the jar file I just created. They were 393 00:18:30,368 --> 00:18:33,329 both put in the same folder with my other 394 00:18:33,329 --> 00:18:36,210 files. That's were I wanted to save them so they happened to show up here in the 395 00:18:36,210 --> 00:18:39,200 package explorer. Here's the funky thing. 396 00:18:39,200 --> 00:18:42,789 Even though we created this manifest, and we created this jar, they don't have quite 397 00:18:42,789 --> 00:18:46,250 the right information that we want. So what we do is we double click on the 398 00:18:46,250 --> 00:18:47,759 manifest file to open it up. 399 00:18:47,759 --> 00:18:49,390 Here's the whole manifest file. 400 00:18:49,390 --> 00:18:51,610 It's got a version, which is 1.0, 401 00:18:51,609 --> 00:18:55,099 and it's got the main class, which is name surfer. Why does it know the main 402 00:18:55,099 --> 00:18:57,558 class is name 403 00:18:57,558 --> 00:19:01,460 surfer? Because I told it. That's the application entry point. Just for 404 00:19:01,460 --> 00:19:03,690 letting me know that I told it, 405 00:19:03,690 --> 00:19:05,590 that's where the application starts. 406 00:19:05,589 --> 00:19:07,629 There's one other thing I need. 407 00:19:07,630 --> 00:19:10,110 408 00:19:10,109 --> 00:19:12,829 What I need to do is say, you know what, 409 00:19:12,829 --> 00:19:14,539 that's a good time, 410 00:19:14,539 --> 00:19:17,559 but you also need to use the ACM libraries. It says, 411 00:19:17,559 --> 00:19:20,899 you didn't tell me about the ACM libraries. You say, well, now I'm 412 00:19:20,900 --> 00:19:22,009 going to add 413 00:19:22,009 --> 00:19:26,519 the coveted third line that was talked about in the manifest file. So I'm actually going to modify the 414 00:19:26,519 --> 00:19:27,278 manifest file and 415 00:19:27,278 --> 00:19:30,089 add something called a class 416 00:19:30,089 --> 00:19:33,589 path. All a class path is, it actually looks just like this, 417 00:19:33,589 --> 00:19:34,639 C-P. 418 00:19:34,640 --> 00:19:37,230 Class path just tells basically 419 00:19:37,230 --> 00:19:39,390 the application 420 00:19:39,390 --> 00:19:42,980 what other stuff were you using. Are there other jar files that you're using? So 421 00:19:42,980 --> 00:19:44,509 what you specify here 422 00:19:44,509 --> 00:19:49,419 is the name of any jar files that you're going to be using as part of your 423 00:19:49,419 --> 00:19:51,380 program, separated by spaces. 424 00:19:51,380 --> 00:19:55,190 So I'm going to use ACM dot jar. Here's ACM dot jar over here. 425 00:19:55,190 --> 00:19:58,400 I'm going to use the ACM libraries, and those are all in some jar file. 426 00:19:58,400 --> 00:20:02,490 I'm also going to use the jar file I just created, name surfer dot jar. 427 00:20:02,490 --> 00:20:06,190 If I had three or more jar files, I'd list them all on the same line. So if 428 00:20:06,190 --> 00:20:08,558 you go and write some application some day where you're like, 429 00:20:08,558 --> 00:20:12,528 hey, I got this jar file for my friend. Here's this jar file I downloaded from the web, which 430 00:20:12,528 --> 00:20:14,140 I wouldn't encourage you to do, 431 00:20:14,140 --> 00:20:16,970 and there's this other job file from somewhere else. You just list them all here with space in 432 00:20:16,970 --> 00:20:18,120 between. 433 00:20:18,119 --> 00:20:21,639 Then we save the file. That's probably the most difficult thing that people 434 00:20:21,640 --> 00:20:24,240 forget. So you save the file. You save the manifest 435 00:20:24,240 --> 00:20:27,410 file. What do you do after you do all this? 436 00:20:27,410 --> 00:20:30,550 Create a jar all over again. 437 00:20:30,549 --> 00:20:32,460 Why? Just trust me. 438 00:20:32,460 --> 00:20:33,539 Here's how it's going to work. I'm going to 439 00:20:33,539 --> 00:20:37,159 do it a little bit different this time. Rather than going to the file menu and picking export, 440 00:20:37,160 --> 00:20:39,340 I'm going to take the advanced course. I'm going to right click 441 00:20:39,339 --> 00:20:41,639 on the project name and click export. 442 00:20:41,640 --> 00:20:44,850 It brings up exactly the same window. 443 00:20:44,849 --> 00:20:46,609 I'm going to export a jar file. 444 00:20:46,609 --> 00:20:50,099 Come over here. What do I want to export? Oh, yeah. It's all this [inaudible] again. 445 00:20:50,099 --> 00:20:53,319 What I want to export is not all this stuff. I just want to export everything 446 00:20:53,319 --> 00:20:55,379 in my default package. 447 00:20:55,380 --> 00:20:58,530 Where do I want to save it? I want to save it in the same place I had before. You 448 00:20:58,529 --> 00:21:00,129 might say, but 449 00:21:00,130 --> 00:21:03,039 aren't you going to replace the one that already exists? Yeah, 450 00:21:03,038 --> 00:21:07,069 I need to replace the one that already exists because I updated my manifest. I need to say 451 00:21:07,069 --> 00:21:09,009 it's not just about you anymore. 452 00:21:09,009 --> 00:21:13,930 Now it also involved ACM jar. You can replace the old one. 453 00:21:13,930 --> 00:21:16,000 So I'm going to put it in the 454 00:21:16,000 --> 00:21:16,950 places before. 455 00:21:16,950 --> 00:21:21,690 Then I click next. Here's the thing about export warnings, export affairs. I don't care. I'm just going to 456 00:21:21,690 --> 00:21:22,420 export. 457 00:21:22,420 --> 00:21:25,480 Here is the only place where things are different. 458 00:21:25,480 --> 00:21:29,259 The second time I go through this whole thing, I don't want to generate another 459 00:21:29,259 --> 00:21:30,119 manifest file. 460 00:21:30,119 --> 00:21:33,859 I generated a manifest file the first time, and then I modified it. 461 00:21:33,859 --> 00:21:39,079 What I want to do is use that modified manifest file. So I say use existing 462 00:21:39,079 --> 00:21:40,509 manifest from workspace, 463 00:21:40,509 --> 00:21:42,470 which is again, just a formal way of saying 464 00:21:42,470 --> 00:21:44,980 use the manifest file that's already there. It 465 00:21:44,980 --> 00:21:48,079 asks me, where is the manifest file? Strangely enough, if you look, 466 00:21:48,079 --> 00:21:52,309 this is exactly the same text 467 00:21:52,309 --> 00:21:53,740 468 00:21:53,740 --> 00:21:57,558 as here. 469 00:21:57,558 --> 00:22:00,359 No coincidence. You just saved it. That's the one you want to use. It's going to be 470 00:22:00,359 --> 00:22:01,549 the same name. 471 00:22:01,549 --> 00:22:02,819 Now notice 472 00:22:02,819 --> 00:22:05,159 which class of the entry point is grayed out. 473 00:22:05,160 --> 00:22:08,719 It's grayed out because I told it before, your entry point is name surfer. 474 00:22:08,719 --> 00:22:12,139 That's in the manifest file. If that's already in a manifest file, I'm using it, it 475 00:22:12,138 --> 00:22:15,649 doesn't need to know it again. So it doesn't even let me specify it again. Just 476 00:22:15,650 --> 00:22:16,830 say that's the difference. 477 00:22:16,829 --> 00:22:18,269 Then I click finish. 478 00:22:18,269 --> 00:22:21,359 They give me one last one. Are you sure you want to override that last jar file? He 479 00:22:21,359 --> 00:22:24,668 was your friend. 480 00:22:24,669 --> 00:22:26,980 I say yes. 481 00:22:26,980 --> 00:22:30,099 We didn't know each other that well. 482 00:22:30,099 --> 00:22:32,649 Now I've created this jar file. 483 00:22:32,650 --> 00:22:33,259 484 00:22:33,259 --> 00:22:36,009 What do I do now? Well, 485 00:22:36,009 --> 00:22:38,640 I kind of come over here, and I say, 486 00:22:38,640 --> 00:22:41,740 here's the jar file I just made. Now 487 00:22:41,740 --> 00:22:44,400 one thing I can do with the jar file is I can double click it. 488 00:22:44,400 --> 00:22:46,860 If I double click on the jar file, 489 00:22:46,859 --> 00:22:49,939 it just starts kicking off the name surfer application. 490 00:22:49,940 --> 00:22:53,950 So I don't need Eclipse anymore to go and run and have a little running dude. 491 00:22:53,950 --> 00:22:58,680 I have a little application. I'm like, oh, yeah. How popular was that? Bob's kind of fallen 492 00:22:58,680 --> 00:23:02,049 off in the meantime. There are some other interesting ones. I was looking at these the 493 00:23:02,049 --> 00:23:05,279 other night. 494 00:23:05,279 --> 00:23:06,639 Verna. After the 495 00:23:06,640 --> 00:23:08,990 '60s, done deal. Thanks for playing. 496 00:23:08,990 --> 00:23:11,849 So name your children Verna. Make a comeback. 497 00:23:11,849 --> 00:23:14,639 So name surfer's just kind of running here. It's fun. It's just a little 498 00:23:14,640 --> 00:23:16,080 stand-alone application. 499 00:23:16,079 --> 00:23:19,409 If you wanted to pack this up and send it to a friend of yours, 500 00:23:19,410 --> 00:23:23,330 you wouldn't just send name surfer dot jar. 501 00:23:23,329 --> 00:23:26,139 What you would do is say, hey, you know what I want to do? 502 00:23:26,140 --> 00:23:27,700 I want to create 503 00:23:27,700 --> 00:23:29,239 - I'll just do it in here - 504 00:23:29,239 --> 00:23:31,150 some new folder. 505 00:23:31,150 --> 00:23:34,630 So I'm going to create some new folder, and I'll call this my program or whatever 506 00:23:34,630 --> 00:23:37,420 you want to call it. I'm just not going to call it name surfer again because I already have a folder 507 00:23:37,420 --> 00:23:39,269 called name surfer. My program. 508 00:23:39,269 --> 00:23:41,308 What I'm going to put in my program, 509 00:23:41,308 --> 00:23:42,200 that folder, 510 00:23:42,200 --> 00:23:43,529 is the jar 511 00:23:43,529 --> 00:23:45,259 of my program. I'm 512 00:23:45,259 --> 00:23:49,720 also going to put in the jar of the ACM library because I also need that jar. That's 513 00:23:49,720 --> 00:23:50,240 separate. 514 00:23:50,240 --> 00:23:54,899 I also need in here any data files like names dot 515 00:23:54,898 --> 00:23:58,329 data. That's all the data that gets read when the program starts. It's 516 00:23:58,329 --> 00:24:01,240 not like magically that's just going to be there now. It's still going to go 517 00:24:01,240 --> 00:24:02,558 and try to find that file. 518 00:24:02,558 --> 00:24:04,210 So I still need to put all that stuff here. 519 00:24:04,210 --> 00:24:07,179 Now this folder is something I can zip up and send it to a friend of mind. When 520 00:24:07,179 --> 00:24:09,298 my friend gets it, they would be like, oh, 521 00:24:09,298 --> 00:24:10,660 name surfer dot 522 00:24:10,660 --> 00:24:12,680 jar. Then they get going. 523 00:24:12,680 --> 00:24:15,950 So now you can package up any program that you've written in this class. 524 00:24:15,950 --> 00:24:16,979 Remember to put in main. 525 00:24:16,979 --> 00:24:19,569 You got to go through this two-part 526 00:24:19,569 --> 00:24:23,759 [inaudible] the jar, export it, process, modify the manifest, create another jar, put it out 527 00:24:23,759 --> 00:24:24,779 there again. 528 00:24:24,779 --> 00:24:26,029 But you're good to go. 529 00:24:26,029 --> 00:24:27,730 Any questions about that? 530 00:24:27,730 --> 00:24:30,549 Now you can package up and share with friends. 531 00:24:30,549 --> 00:24:33,849 What's even cooler than sharing with friends that you can email stuff to 532 00:24:33,849 --> 00:24:35,859 is sharing with friends on the web. 533 00:24:35,859 --> 00:24:39,319 You just have millions of friends on the web. Most of them you just 534 00:24:39,319 --> 00:24:42,009 don't know about, but they're probably on in the late hours of the night, 535 00:24:42,009 --> 00:24:44,558 looking at your web pages 536 00:24:44,558 --> 00:24:46,190 and things. You can actually take 537 00:24:46,190 --> 00:24:47,809 any 538 00:24:47,809 --> 00:24:51,019 files that you create here, like jar files, and make them available in a web browser. 539 00:24:51,019 --> 00:24:54,029 There's one other thing I should mention, and this is kind of a little thing. Before 540 00:24:54,029 --> 00:24:55,129 you go and 541 00:24:55,130 --> 00:24:58,710 create all this stuff and send it off to your mom and dad and be like, mom, dad, breakout. Go play. 542 00:24:58,710 --> 00:25:00,220 It's a good time. 543 00:25:00,220 --> 00:25:04,339 In order for them to run your jar files, they need to have the Java run time 544 00:25:04,339 --> 00:25:05,470 environment installed. 545 00:25:05,470 --> 00:25:08,600 Remember on the second week of class where we said go 546 00:25:08,599 --> 00:25:10,158 to the CS106 web site. 547 00:25:10,159 --> 00:25:13,539 You need to download a clip. There's this thing called the JRE you also need to 548 00:25:13,538 --> 00:25:14,529 download. 549 00:25:14,529 --> 00:25:15,339 If you have a make, 550 00:25:15,339 --> 00:25:18,720 the JRE in most cases is already installed. If you have Windows, it's not 551 00:25:18,720 --> 00:25:19,410 installed. 552 00:25:19,410 --> 00:25:22,630 They need to go down, and you can send them to the CS106 page 553 00:25:22,630 --> 00:25:26,610 and say download the JRE. Here's a copy of handout No. 5. 554 00:25:26,609 --> 00:25:28,089 Go ahead and install it, 555 00:25:28,089 --> 00:25:31,119 and then they can run your programs. Your program can't run 556 00:25:31,119 --> 00:25:33,808 if the computer doesn't have Java, right? It's a bunch of stuff that's going 557 00:25:33,808 --> 00:25:35,599 to execute Java byte code, 558 00:25:35,599 --> 00:25:36,439 and your computer's like, 559 00:25:36,440 --> 00:25:39,110 what's Java byte code? 560 00:25:39,109 --> 00:25:41,979 I don't know what to do with it, so it won't run. They need the Java Runtime 561 00:25:41,980 --> 00:25:43,099 Environment. 562 00:25:43,099 --> 00:25:46,639 Now assuming someone has the JRE, 563 00:25:46,640 --> 00:25:49,538 they can go to a web page. 564 00:25:49,538 --> 00:25:51,789 You might put some page on the web 565 00:25:51,789 --> 00:25:56,230 that allows you to load your applet. Your applet is just a webified 566 00:25:56,230 --> 00:25:57,610 version of your program. 567 00:25:57,609 --> 00:25:59,329 So here 568 00:25:59,329 --> 00:26:02,429 look. It's running inside a web browser. This isn't the actual 569 00:26:02,430 --> 00:26:06,740 application. This is my web browser. I could go to 570 00:26:06,740 --> 00:26:07,190 571 00:26:07,190 --> 00:26:09,759 some search engine from 572 00:26:09,759 --> 00:26:11,759 here. I'm sitting in the web browser. 573 00:26:11,759 --> 00:26:14,390 I'm not just running a regular application 574 00:26:14,390 --> 00:26:18,320 on my desktop. This guy's actually running in my web browser. 575 00:26:18,319 --> 00:26:20,178 576 00:26:20,179 --> 00:26:21,460 Here's how I make it happen. 577 00:26:21,460 --> 00:26:23,730 I create a web page. 578 00:26:23,730 --> 00:26:27,130 If you don't know about HTML and creating web pages, 579 00:26:27,130 --> 00:26:29,730 unfortunately I can't explain that to you in five minutes. 580 00:26:29,730 --> 00:26:32,960 What I can show you is basically what this file's going to look like. So if you 581 00:26:32,960 --> 00:26:37,029 know a little bit of HTML or you just want to essentially copy and paste this 582 00:26:37,029 --> 00:26:37,700 idea, 583 00:26:37,700 --> 00:26:38,740 this will work for you. 584 00:26:38,740 --> 00:26:42,609 So all you do is say - the entire page 585 00:26:42,609 --> 00:26:44,750 that allows your applet to run. You 586 00:26:44,750 --> 00:26:47,990 say this page is HTML. There's these little things called tags. 587 00:26:47,990 --> 00:26:52,759 The name of that page is name surfer. I want to create a little table. I'm going to create a little border 588 00:26:52,759 --> 00:26:55,529 around my application. 589 00:26:55,529 --> 00:26:59,170 What's my application? My whole application is right here. 590 00:26:59,170 --> 00:27:00,880 I have an applet. 591 00:27:00,880 --> 00:27:02,770 What's the name of the archive, 592 00:27:02,769 --> 00:27:08,019 which is a Java archive that contains my applet? It's name surfer dot jar. 593 00:27:08,019 --> 00:27:11,359 Code is what's the entry point. This guy no long has a manifest 594 00:27:11,359 --> 00:27:14,159 file available to us. What's my entry point? 595 00:27:14,160 --> 00:27:17,610 Name surfer dot class. That's where you start running. So it says I'm going to go 596 00:27:17,609 --> 00:27:20,069 name surfer dot class, find its name. That's where I start running. 597 00:27:20,069 --> 00:27:23,128 The space I'm going to give you to run on the screen is 598 00:27:23,128 --> 00:27:24,459 700 by 599 00:27:24,460 --> 00:27:26,179 500. That little snippet of code 600 00:27:26,179 --> 00:27:30,429 is what goes on whatever web server this is serving on. It 601 00:27:30,429 --> 00:27:32,240 looks for those jar files, 602 00:27:32,240 --> 00:27:35,670 slaps them into the page and then they're good to go to run more java 603 00:27:35,670 --> 00:27:38,190 program inside 604 00:27:38,190 --> 00:27:41,269 their web browser. How many people know HTML? 605 00:27:41,269 --> 00:27:44,910 You folks. There's some number of folks that this might be a reasonable 606 00:27:44,910 --> 00:27:47,849 thing to do. If not, you just don't need to worry about it. It's not a big deal. 607 00:27:47,848 --> 00:27:50,789 608 00:27:50,789 --> 00:27:53,658 The one other thing you should know if you create a web page 609 00:27:53,659 --> 00:27:57,409 is that when something's running in the web page, it doesn't have access to the 610 00:27:57,409 --> 00:27:59,480 rest of the file system. 611 00:27:59,480 --> 00:28:01,380 What that means is 612 00:28:01,380 --> 00:28:06,080 if I actually happen to be over here - notice I have index dot HTML. I have name 613 00:28:06,079 --> 00:28:08,629 surfer dot jar, and I have ACM dot jar. 614 00:28:08,630 --> 00:28:11,940 What happens in my names dash data 615 00:28:11,940 --> 00:28:13,910 file? It doesn't exist. 616 00:28:13,910 --> 00:28:17,220 Why doesn't it exist? Because I couldn't read it anyway. Once I'm running on 617 00:28:17,220 --> 00:28:20,980 the web browser, for security reasons, it doesn't let you go in and pull stuff 618 00:28:20,980 --> 00:28:22,549 out of your file 619 00:28:22,549 --> 00:28:27,269 system. If it did, people could do really bad things to your computer. So 620 00:28:27,269 --> 00:28:30,379 what you need to do if you want to find that data, you let 621 00:28:30,380 --> 00:28:33,490 us run name surfer on the web. What did you do? 622 00:28:33,490 --> 00:28:35,569 Here's the dirty little secret. I 623 00:28:35,569 --> 00:28:38,839 actually created a giant array that had all the data in it 624 00:28:38,839 --> 00:28:40,699 and made it part of the program. 625 00:28:40,700 --> 00:28:44,120 So sometimes you can do stuff like that if you don't actually want to read from 626 00:28:44,119 --> 00:28:44,829 a file. 627 00:28:44,829 --> 00:28:48,058 The other thing you can do is you can take those files and include them in the 628 00:28:48,058 --> 00:28:48,678 jar file 629 00:28:48,679 --> 00:28:52,419 because the jar file cannot only have compiled [inaudible]. It can also have data files. That's 630 00:28:52,419 --> 00:28:55,040 another way of doing it if you want to do it that 631 00:28:55,039 --> 00:28:57,700 way. We don't have time to go into all the details. It's kind of the same 632 00:28:57,700 --> 00:28:58,359 process. 633 00:28:58,358 --> 00:29:03,149 When you're exporting stuff to the jar file, you include some data files in there. 634 00:29:03,150 --> 00:29:04,919 So what's creating the executable. 635 00:29:04,919 --> 00:29:08,210 Now that we know all this funky stuff about executables put on a 636 00:29:08,210 --> 00:29:11,660 web page if I want. I'm feeling happy. I'm good to go. 637 00:29:11,660 --> 00:29:14,558 It's time to come back to our friend, 638 00:29:14,558 --> 00:29:17,720 standard Java. Standard Java's what allowed us to think 639 00:29:17,720 --> 00:29:20,370 about doing this stuff because we learned about main. 640 00:29:20,369 --> 00:29:24,179 I want to show you a couple examples of programs that actually don't use the 641 00:29:24,180 --> 00:29:25,389 ACM libraries at all 642 00:29:25,388 --> 00:29:28,449 to show you why we use the ACM libraries. One of the things you might be wondering 643 00:29:28,450 --> 00:29:29,809 is 644 00:29:29,809 --> 00:29:33,609 why weren't we just doing the standard Java thing the whole time? 645 00:29:33,609 --> 00:29:35,389 Part of the reason is 646 00:29:35,390 --> 00:29:38,710 things are just so much easier and cooler when you have the ACM libraries. So if 647 00:29:38,710 --> 00:29:40,920 you go back over to Eclipse, 648 00:29:40,920 --> 00:29:44,440 we're kind of done with name surfer and all this manifest stuff. 649 00:29:44,440 --> 00:29:48,480 Here's a program that's written in standard Java that writes out hello world on 650 00:29:48,480 --> 00:29:49,860 the screen. 651 00:29:49,859 --> 00:29:52,990 This is something you kind of did in the first class by saying public class hello 652 00:29:52,990 --> 00:29:55,778 world extends console program in printlin. 653 00:29:55,778 --> 00:29:58,980 Hello world out to the screen, and you would've gotten it in the console. 654 00:29:58,980 --> 00:30:02,680 So what's different here? What's different is we have public class 655 00:30:02,680 --> 00:30:03,769 hello world, 656 00:30:03,769 --> 00:30:07,319 and it doesn't extend anything. It doesn't extend program. It doesn't extend 657 00:30:07,319 --> 00:30:08,329 console program. 658 00:30:08,329 --> 00:30:13,169 There are no imports for the ACM libraries. We're not using any of the ACM stuff. 659 00:30:13,170 --> 00:30:16,759 So we don't have a console program. We don't have a nice console 660 00:30:16,759 --> 00:30:20,289 that we write stuff out to that displays in a nice little window. 661 00:30:20,289 --> 00:30:24,159 What we do have is something called the system output console. If we want to 662 00:30:24,160 --> 00:30:28,130 put stuff on that, it looks real similar to what you had before. We used printlin, 663 00:30:28,130 --> 00:30:31,680 which is why we made the method that you used called printlin to match this. 664 00:30:31,680 --> 00:30:36,789 But we need to say system dot out dot prinlin and then the text we want to print out. 665 00:30:36,789 --> 00:30:39,670 Again, here I have a main method. My main method can have whatever I want in it. 666 00:30:39,670 --> 00:30:41,650 This is just where execution starts. 667 00:30:41,650 --> 00:30:43,370 So if I 668 00:30:43,369 --> 00:30:45,019 669 00:30:45,019 --> 00:30:47,038 compile this and run it - let me show you why. 670 00:30:47,038 --> 00:30:50,950 This world is not all that cool. 671 00:30:50,950 --> 00:30:53,409 Here's hello world. 672 00:30:53,409 --> 00:30:54,470 It just ran. 673 00:30:54,470 --> 00:30:58,850 You're like, I don't see anything. 674 00:30:58,849 --> 00:31:02,219 You don't get a cool window that comes up and is like, hello 675 00:31:02,220 --> 00:31:04,069 world. 676 00:31:04,069 --> 00:31:06,450 You have the system console. 677 00:31:06,450 --> 00:31:10,029 The system console if you happen to be using a development environment like 678 00:31:10,029 --> 00:31:11,259 Eclipse or something else, 679 00:31:11,259 --> 00:31:14,490 it's basically just a window in that development environment that shows 680 00:31:14,490 --> 00:31:15,809 messages that you print out. 681 00:31:15,809 --> 00:31:19,329 If you happen to be in the bad old days that I think I erased over here where you 682 00:31:19,329 --> 00:31:22,168 have command line text where you actually type stuff in, the 683 00:31:22,169 --> 00:31:25,169 console would just be that same window where the text would appear where you 684 00:31:25,169 --> 00:31:26,180 type 685 00:31:26,180 --> 00:31:29,630 stuff. If you don't get it in a separate window, it's not that cool. A lot 686 00:31:29,630 --> 00:31:33,600 of times, this window's close anyway. If you 687 00:31:33,599 --> 00:31:37,559 wanted to kick it up a notch, why use the console? 688 00:31:37,559 --> 00:31:41,789 Why not do something graphical. So here's graphical hello world. 689 00:31:41,789 --> 00:31:43,598 What we want to do is 690 00:31:43,598 --> 00:31:45,278 create 691 00:31:45,278 --> 00:31:48,778 a window that is going to have some title associated with it. We're going 692 00:31:48,778 --> 00:31:51,849 to put the text hello world in that window. 693 00:31:51,849 --> 00:31:54,929 What do we need to do? Again, execution starts at main. 694 00:31:54,930 --> 00:31:57,570 We need to create something called a J frame, which you never had to worry 695 00:31:57,569 --> 00:31:58,628 about before. 696 00:31:58,628 --> 00:32:02,359 What's a J frame? It's actually a frame that's going to hold the window. 697 00:32:02,359 --> 00:32:05,299 We're going to start running our application. 698 00:32:05,299 --> 00:32:08,700 It's going to create a little window for us that we're going to display stuff in. 699 00:32:08,700 --> 00:32:10,190 What are we going to put in that window? 700 00:32:10,190 --> 00:32:13,100 We're going to put a label. J labels you've seen before. This is just like 701 00:32:13,099 --> 00:32:14,089 you've seen. 702 00:32:14,089 --> 00:32:16,858 We're going to create a J label that's called hello world, 703 00:32:16,858 --> 00:32:20,388 and we want this label to be center justified as opposed to left justified 704 00:32:20,388 --> 00:32:24,048 or right justified. So I need to say J label dot center to center justify it. 705 00:32:24,048 --> 00:32:27,660 If I don't give it a justification, it'll by default by left justified and look kind of ugly 706 00:32:27,660 --> 00:32:29,220 because we want it 707 00:32:29,220 --> 00:32:32,029 center. Then I add this label to my frame. 708 00:32:32,029 --> 00:32:35,889 So similar to the idea of having a canvas and adding stuff to the canvas, it's 709 00:32:35,890 --> 00:32:38,790 exactly analogous. We want to make it just as easy. So when you saw standard 710 00:32:38,789 --> 00:32:39,480 Java, 711 00:32:39,480 --> 00:32:41,230 all the same concepts would apply. 712 00:32:41,230 --> 00:32:45,450 Here, we're just adding the J label, which as you know now, is a J component in the 713 00:32:45,450 --> 00:32:46,860 big Java hierarchy. 714 00:32:46,859 --> 00:32:49,648 J components can be added to J frames. 715 00:32:49,648 --> 00:32:52,489 So we have a J label that gets added to a J frame. 716 00:32:52,490 --> 00:32:56,039 I set the size for that J frame, which is 500 by 300. That tells me 717 00:32:56,039 --> 00:32:58,220 how big the window's going to be when it starts. 718 00:32:58,220 --> 00:33:00,860 Then there's this other stuff that I need to do. You would 719 00:33:00,859 --> 00:33:02,000 think 720 00:33:02,000 --> 00:33:05,359 why do I need to do that? It doesn't make any sense 721 00:33:05,359 --> 00:33:08,589 that I would not otherwise want to have it this way. Here's what I need to do. 722 00:33:08,589 --> 00:33:11,879 If someone clicks close on 723 00:33:11,880 --> 00:33:12,480 the window, 724 00:33:12,480 --> 00:33:13,940 I need to say, hey, 725 00:33:13,940 --> 00:33:17,830 if someone clicked that, then you need to close yourself. Otherwise, the window goes away and 726 00:33:17,829 --> 00:33:19,669 the application keeps running. 727 00:33:19,670 --> 00:33:23,160 It seems odd, but we need to have that there for this application to stop running. 728 00:33:23,160 --> 00:33:24,440 Then we say 729 00:33:24,440 --> 00:33:26,580 window, I know I created you and everything. 730 00:33:26,579 --> 00:33:28,359 You need to make yourself visible. 731 00:33:28,359 --> 00:33:31,139 Otherwise, no one will be able to see you. You're like, 732 00:33:31,140 --> 00:33:35,290 why would I create a window that I wasn't going to make visible? Yeah, 733 00:33:35,289 --> 00:33:37,200 that's why we use the ACM libraries. 734 00:33:37,200 --> 00:33:40,380 So we need to make sure that this guy's visibility's true. 735 00:33:40,380 --> 00:33:41,720 If we run this, 736 00:33:41,720 --> 00:33:45,089 here's graphical hello. So after all this stuff, 737 00:33:45,089 --> 00:33:50,909 here's graphical hello. Yeah, 738 00:33:50,910 --> 00:33:54,558 would you want all that explained to you so you can get hello world? 739 00:33:54,558 --> 00:33:56,460 You're like, 740 00:33:56,460 --> 00:33:59,650 I'm writing a social network. I don't need to worry about hello world 741 00:33:59,650 --> 00:34:01,180 in the middle of my screen. 742 00:34:01,180 --> 00:34:03,130 That's because you have the ACM libraries. 743 00:34:03,130 --> 00:34:06,850 So you're like, okay, let's kick it up even one more notch. You're 744 00:34:06,849 --> 00:34:10,029 like, [inaudible] all this mouse stuff and interaction, right? That should be 745 00:34:10,030 --> 00:34:13,830 something I get some benefit from having standard Java. So we'll 746 00:34:13,829 --> 00:34:16,038 have an interactive version of hello. 747 00:34:16,039 --> 00:34:19,219 Center the interactive version of hello. Now some of this stuff should begin to get 748 00:34:19,219 --> 00:34:21,588 a little more 749 00:34:21,588 --> 00:34:24,228 repetitive in the sense that you have your main. You have your J frame. The 750 00:34:24,228 --> 00:34:27,439 frame is called interactive hello. That's the title of that window. 751 00:34:27,440 --> 00:34:29,700 What we're going to add to this J frame is a new 752 00:34:29,699 --> 00:34:31,978 class that we're going to create called a moving label. 753 00:34:31,978 --> 00:34:34,528 I'll show you what a moving label down in just a second, but we need to set the size 754 00:34:34,528 --> 00:34:35,769 of the window, 755 00:34:35,769 --> 00:34:39,869 set default close operation exit on close. 756 00:34:39,869 --> 00:34:43,699 Set visibility to true. Basically all this does is create this window of a 757 00:34:43,699 --> 00:34:44,610 particular size. 758 00:34:44,610 --> 00:34:48,360 It's going to add this thing called a moving label to it. Moving label's just 759 00:34:48,360 --> 00:34:51,329 another class I create. What's a moving label? 760 00:34:51,329 --> 00:34:53,999 A moving label is a J component. 761 00:34:53,998 --> 00:34:57,348 It needs to be a J component because I'm going to add it to a frame. 762 00:34:57,349 --> 00:35:00,778 To display something on a frame, I can only display components on the 763 00:35:00,778 --> 00:35:02,619 frame. This is going to extend component. 764 00:35:02,619 --> 00:35:05,309 It's going to implement our friend, mouse listener. 765 00:35:05,309 --> 00:35:07,969 It's going to listen for the mouse. You're like, oh, I remember mouse 766 00:35:07,969 --> 00:35:11,048 listener. That where the mouse got clicked and dragged. That stuff's 767 00:35:11,048 --> 00:35:12,498 exactly the same. 768 00:35:12,498 --> 00:35:16,468 So I have my constructor. What my constructor has, it has some starting text for this label 769 00:35:16,469 --> 00:35:18,559 at its starting X and Y location. 770 00:35:18,559 --> 00:35:20,679 That should look kind of familiar to you. 771 00:35:20,679 --> 00:35:23,670 Basically I just store off the text. I store it at X 772 00:35:23,670 --> 00:35:26,188 and Y. This guy wants to listen for mouse events. 773 00:35:26,188 --> 00:35:29,578 So it says add a mouse listener, and it needs to say 774 00:35:29,579 --> 00:35:31,190 if you get some mouse event, 775 00:35:31,190 --> 00:35:34,789 send them to this. 776 00:35:34,789 --> 00:35:37,949 So this is a little bit different than you've written in your programs before 777 00:35:37,949 --> 00:35:41,079 where you just said add mouse listener. You just had an 778 00:35:41,079 --> 00:35:46,140 open [inaudible]. That's because we kind of took 779 00:35:46,139 --> 00:35:49,338 care of the rest of this stuff for you. Here's where things get a little bit funky. 780 00:35:49,338 --> 00:35:52,788 The difference between this and thinking about having some sort of label that you 781 00:35:52,789 --> 00:35:56,229 just display on a canvas, some text that 782 00:35:56,228 --> 00:35:58,208 just sits there, 783 00:35:58,208 --> 00:36:01,958 is that this guy now has to worry about what's known as painting himself. 784 00:36:01,958 --> 00:36:05,498 That means it needs to draw itself on the screen. Well, when I had 785 00:36:05,498 --> 00:36:07,698 labels before, they just knew how to draw themselves. 786 00:36:07,699 --> 00:36:10,619 Yeah, that's because we gave you a label that was a little bit smarter and knew that it 787 00:36:10,619 --> 00:36:12,430 was a label that should draw itself. 788 00:36:12,429 --> 00:36:15,528 This guy needs to be told to draw 789 00:36:15,528 --> 00:36:18,900 himself. There's a method called paint component that gets called whenever this guys 790 00:36:18,900 --> 00:36:21,749 gets displayed on the screen. There's some other thread that's going to call 791 00:36:21,748 --> 00:36:23,109 it for you automatically. 792 00:36:23,110 --> 00:36:25,539 Here's the graphics 793 00:36:25,539 --> 00:36:27,129 context in which your going to call 794 00:36:27,128 --> 00:36:30,308 yourself. Within that graphics context, I'm going to draw some string. 795 00:36:30,309 --> 00:36:33,309 The actual method name and everything is not important here. It just shows you that 796 00:36:33,309 --> 00:36:36,459 there is extra stuff you need to worry about, which is why we didn't want 797 00:36:36,458 --> 00:36:38,268 to do all this stuff to begin 798 00:36:38,268 --> 00:36:41,698 with. This stuff you've seen before. What happens if a mouse is clicked? I get the new 799 00:36:41,699 --> 00:36:42,659 XY location. 800 00:36:42,659 --> 00:36:44,149 I repaint. 801 00:36:44,150 --> 00:36:47,418 What does repaint mean? It means redraw yourself. 802 00:36:47,418 --> 00:36:51,878 I'm going to redraw myself at this new XY location. When I call 803 00:36:51,878 --> 00:36:52,608 repaint, 804 00:36:52,608 --> 00:36:55,578 someone comes along and says, hey, to repaint this area, 805 00:36:55,579 --> 00:36:59,039 I'm going to call your paint component method so you can repaint yourself. 806 00:36:59,039 --> 00:36:59,739 807 00:36:59,739 --> 00:37:04,210 Whoa, this is really weird. I'm over here. I get a mouse click, 808 00:37:04,210 --> 00:37:07,699 and I know that I want to redraw myself. But rather than telling 809 00:37:07,699 --> 00:37:09,489 myself directly to redraw myself, 810 00:37:09,489 --> 00:37:13,279 I go and tell the system, I need to get repainted. Then the system 811 00:37:13,280 --> 00:37:13,789 says, 812 00:37:13,789 --> 00:37:15,240 that's the start of Jabba the Hutt kind 813 00:37:15,239 --> 00:37:20,169 of sitting there fat and happy. 814 00:37:20,170 --> 00:37:22,989 815 00:37:22,989 --> 00:37:25,139 Some day, if you actually - 816 00:37:25,139 --> 00:37:26,269 we won't get into 817 00:37:26,269 --> 00:37:28,809 818 00:37:28,809 --> 00:37:29,829 it. 819 00:37:29,829 --> 00:37:33,139 You go and say I need to repaint myself. It says, okay, you 820 00:37:33,139 --> 00:37:36,809 need to repaint yourself. Well, when I'm ready for you to repaint yourself, 821 00:37:36,809 --> 00:37:39,419 I'll call your paint component method. 822 00:37:39,418 --> 00:37:41,599 Until then, you don't repaint yourself. So it 823 00:37:41,599 --> 00:37:44,519 delays other stuff in the system to worry about, and then oh, yeah. There 824 00:37:44,519 --> 00:37:46,400 was you. You asked to get repainted. 825 00:37:46,400 --> 00:37:48,869 I'll call your paint component. You say, okay, well, now I'm going 826 00:37:48,869 --> 00:37:52,318 to draw myself at the new XY location. 827 00:37:52,318 --> 00:37:55,349 So it kind of convoluted the whole notion of 828 00:37:55,349 --> 00:37:58,890 you're doing something here, and you're asking someone else to do something for 829 00:37:58,889 --> 00:38:03,170 you. Then they're going to call you back to do what you originally intended to do. 830 00:38:03,170 --> 00:38:06,838 Now it makes a little bit more sense after we talked about threads and after you've seen 831 00:38:06,838 --> 00:38:08,690 all this stuff. 832 00:38:08,690 --> 00:38:11,309 Third day of class, not so hot. 833 00:38:11,309 --> 00:38:14,069 So if we run this, 834 00:38:14,068 --> 00:38:16,619 this is called interactive below. 835 00:38:16,619 --> 00:38:20,289 Basically, what it does is it just brings up our particular message, CS106A rocks 836 00:38:20,289 --> 00:38:22,670 in the middle of the screen. Now every time I click the 837 00:38:22,670 --> 00:38:25,898 mouse button because this is the mouse click event over here. 838 00:38:25,898 --> 00:38:27,679 Every time I click the mouse button, 839 00:38:27,679 --> 00:38:31,690 the XY location of the mouse becomes the new base point 840 00:38:31,690 --> 00:38:33,369 for the text that gets drawn. 841 00:38:33,369 --> 00:38:37,380 So it just moves around the screen. 842 00:38:37,380 --> 00:38:39,709 Any questions about that? 843 00:38:39,708 --> 00:38:41,489 So this is standard Java. 844 00:38:41,489 --> 00:38:45,429 You've seen all the concepts using the ACM 845 00:38:45,429 --> 00:38:48,019 libraries. The notion of adding things, having mouse listeners. As 846 00:38:48,018 --> 00:38:51,318 a matter of fact, the whole mouse listeners concept, we just took the 847 00:38:51,318 --> 00:38:55,648 standard Java ideas and used them sort of in conjunction with the ACM libraries. 848 00:38:55,648 --> 00:38:58,368 But there's a lot of things in the ACM libraries that just made it so much 849 00:38:58,369 --> 00:39:01,798 easier to, for example, to graphics contest entries or to write a social 850 00:39:01,798 --> 00:39:05,099 network. So you're welcome to continue to use the ACM 851 00:39:05,099 --> 00:39:06,539 libraries after this 852 00:39:06,539 --> 00:39:09,929 class. Some people were wondering why we use these libraries, and this is the 853 00:39:09,929 --> 00:39:13,568 reason why. There's a whole lot of stuff you'd have to worry about 854 00:39:13,568 --> 00:39:19,528 otherwise. Questions? [Inaudible]. 855 00:39:19,528 --> 00:39:24,248 You'd be using your favorite word processor, like notepad. 856 00:39:24,248 --> 00:39:28,228 There's actually some places which I won't name, but 857 00:39:28,228 --> 00:39:30,989 it's actually reasonable that some schools in your first 858 00:39:30,989 --> 00:39:33,749 programming class, what you do is they say, you need to have notepad, 859 00:39:33,748 --> 00:39:35,578 or you need to have some text editor. 860 00:39:35,579 --> 00:39:38,660 Then we're going to do command line stuff. You're going to type in name 861 00:39:38,659 --> 00:39:42,778 surfer, names dash data dot text to run your program. Then everything is going to be 862 00:39:42,778 --> 00:39:43,838 [inaudible]. 863 00:39:43,838 --> 00:39:47,969 So one thing I want to leave you with now, in our final few moments together, is 864 00:39:47,969 --> 00:39:50,988 sort of a notion - we're still going to meet next week, talk about life after this 865 00:39:50,989 --> 00:39:54,170 class, but if you want to go on in terms of learning more 866 00:39:54,170 --> 00:39:57,079 about Java, especially standard Java, 867 00:39:57,079 --> 00:40:00,548 we sort of just started things off by giving you this book, which 868 00:40:00,548 --> 00:40:03,869 talks all about the ACM libraries. This, I think, is a great book to actually 869 00:40:03,869 --> 00:40:06,209 learn everything with and use the ACM libraries. 870 00:40:06,208 --> 00:40:12,178 But if you want to go on, what are some other resources you can use? [Inaudible]. 871 00:40:12,179 --> 00:40:15,989 It's not pretty. If you go to the Java section of any bookstore, just 872 00:40:15,989 --> 00:40:19,599 be prepared to stay a while. One book that I would recommend, not that I get any kickbacks from these 873 00:40:19,599 --> 00:40:22,989 folks, called Learning Java. It's actually a pretty good time. Some of the 874 00:40:22,989 --> 00:40:26,798 examples you actually saw here were based on this book. It's a little big. 875 00:40:26,798 --> 00:40:29,978 That's why we don't use it as a textbook in this class. Will 876 00:40:29,978 --> 00:40:32,038 we break the 1,000-page mark. 877 00:40:32,039 --> 00:40:35,640 It's so close. No, 950. Sorry, close. There 878 00:40:35,639 --> 00:40:40,929 879 00:40:40,929 --> 00:40:44,259 are some other books. Actually, the original specification of the Java 880 00:40:44,259 --> 00:40:46,809 programming language. This is an older version of the book. This was when I 881 00:40:46,809 --> 00:40:49,070 was a wee tyke in the days of yore and got the old version. 882 00:40:49,070 --> 00:40:52,100 I forget what version they're up to now. This was second edition. I think now they're up 883 00:40:52,099 --> 00:40:53,889 to three or four. Something like that. The 884 00:40:53,889 --> 00:40:55,480 books are a little bit bigger, but 885 00:40:55,480 --> 00:40:59,329 for a book that specifies the language, Java, it's actually very well-written as a 886 00:40:59,329 --> 00:41:01,958 reference. So I'd recommend this as well. 887 00:41:01,958 --> 00:41:05,118 If you're into oh, I want it all, 888 00:41:05,119 --> 00:41:06,280 Big Java. 889 00:41:06,280 --> 00:41:07,489 It's big. 890 00:41:07,489 --> 00:41:10,778 I think it might actually cross the 1,000 page - oh, yeah. 891 00:41:10,778 --> 00:41:13,719 It's like 892 00:41:13,719 --> 00:41:16,988 1,200. If you really want to get hardcore and you're all about web-based 893 00:41:16,989 --> 00:41:19,059 Java, 894 00:41:19,059 --> 00:41:22,809 Java Server Programming. Everything you would want and a lot of things you don't 895 00:41:22,809 --> 00:41:26,099 want to know. Everything you want to know and more. 896 00:41:26,099 --> 00:41:28,109 That's just a small set. 897 00:41:28,108 --> 00:41:30,958 So these are just a few books I'd recommend if you want to go on beyond 898 00:41:30,958 --> 00:41:31,899 this class. 899 00:41:31,900 --> 00:41:35,460 But you can go into any bookstore, and you get inundated with that kind of stuff. 900 00:41:35,460 --> 00:41:38,740 Now you have a context for putting all the pieces together because 901 00:41:38,739 --> 00:41:41,279 you've seen all the things that you actually need to know to be able to 902 00:41:41,280 --> 00:41:45,579 work with the huge set of tools that Java actually 903 00:41:45,579 --> 00:41:49,159 has. Any questions about any of this stuff? 904 00:41:49,159 --> 00:41:50,429 You're good to go? 905 00:41:50,429 --> 00:41:53,369 All right. I'll let you go a couple minutes early because most of the time, I let you go a couple 906 00:41:53,369 --> 00:41:54,660 minutes late. 907 00:41:54,659 --> 00:41:55,219 Have a good weekend.