WEBVTT 1 00:00:01.001 --> 00:00:03.001 In this demo I'm going to show you how to 2 00:00:03.002 --> 00:00:04.118 compile Java source files 3 00:00:04.220 --> 00:00:06.000 at the Windows command prompt 4 00:00:06.002 --> 00:00:07.221 without using BlueJ. 5 00:00:09.002 --> 00:00:10.226 To add a source code can be compiled 6 00:00:10.227 --> 00:00:13.110 at the command prompt using the javac command 7 00:00:13.113 --> 00:00:15.226 that's available if you have the Java SDK 8 00:00:15.227 --> 00:00:17.113 installed on your computer. 9 00:00:18.111 --> 00:00:19.226 When BlueJ compiles a class 10 00:00:19.228 --> 00:00:21.222 it uses the javac command, 11 00:00:21.225 --> 00:00:23.220 it just hides the details from you. 12 00:00:24.227 --> 00:00:27.114 I have a folder containing Java source files 13 00:00:27.115 --> 00:00:29.226 for all the classes in the adventure game programme. 14 00:00:31.002 --> 00:00:33.116 I can list the contents of that folder 15 00:00:34.225 --> 00:00:37.007 and you can see the source files there. 16 00:00:38.111 --> 00:00:41.113 Let's try compiling the Item class, 17 00:00:41.229 --> 00:00:49.112 type the command javac then Item.java and return. 18 00:00:50.119 --> 00:00:52.229 I don't get any message which is a good thing 19 00:00:53.001 --> 00:00:55.110 because javac only will give me messages 20 00:00:55.112 --> 00:00:57.008 if there are compilation errors. 21 00:00:58.228 --> 00:01:01.229 Lets list the contents of the folder now 22 00:01:03.003 --> 00:01:06.009 and you can see there's a new file item.class 23 00:01:06.111 --> 00:01:09.112 which contains the compiled item class. 24 00:01:11.228 --> 00:01:14.008 I can compile all the classes in the folder 25 00:01:14.112 --> 00:01:16.119 at once using a wildcard. 26 00:01:17.008 --> 00:01:24.226 Type javac *.java and return and again 27 00:01:25.000 --> 00:01:28.224 there's no message so compilation has been successful. 28 00:01:29.007 --> 00:01:32.008 If I list the contents of the folder you can see that 29 00:01:32.009 --> 00:01:36.112 there's now a class file for everyone of the source files. 30 00:01:38.001 --> 00:01:40.001 Finally, I'm going to run the programme. 31 00:01:40.112 --> 00:01:41.110 In the previous demo 32 00:01:41.112 --> 00:01:43.009 I showed you how to run a Java programme 33 00:01:43.111 --> 00:01:45.006 packaged as a jar file and that's 34 00:01:45.008 --> 00:01:47.220 normally the most convenient way to run a programme. 35 00:01:48.224 --> 00:01:50.118 However, you can run a programme 36 00:01:50.221 --> 00:01:52.228 by using the Java command and specifying 37 00:01:53.000 --> 00:01:55.113 the name of the class that contains the main method. 38 00:01:56.003 --> 00:01:58.227 This will work if compiled class files are available 39 00:01:58.229 --> 00:02:01.119 for all the classes that the programme needs. 40 00:02:03.001 --> 00:02:04.114 So lets try that, 41 00:02:04.227 --> 00:02:08.112 java and the name of the class with the main method 42 00:02:08.114 --> 00:02:13.111 is Game and enter and a welcome message is shown 43 00:02:13.112 --> 00:02:14.114 and we can just 44 00:02:14.119 --> 00:02:18.002 go through the rest of the programme as before.