Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
1 CS 201, Getting Started in the Lab Compiling, running, getting files, printing source code and output: 1. We will be using TextPad as our editor and programming environment for Java. You can find the TextPad application on the lab machines by going through Start, Programs. 2. Under Tools in the TextPad menu you will find 3 options related to java: Compile Java, Run Java Application, and Run Java Applet. For the time being our primary concern is compiling and running applications. Applets come later. 3. Under Tools in the TextPad menu you will also see a plain “Run…” option. This is mentioned only because you will probably mistakenly try to use this once. Using this option to try and run a Java program will either bring up a dialog box asking what application to run, or a mystery error message. You need to make sure you’re trying to run your programs with the Run Java Application option. 4. The documentation for Java is not available through TextPad. On the class Web page there is a link to the Java API Documentation, which is located on the Sun web site. You might want to add this to your favorites list so that you can have it handy in your Web browser while you’re working on programming. 5. As noted on the Web page for the class, downloading program files provided by me isn’t very convenient. This is what you have to do: Open the Web page containing the Java code, edit/select all, edit/copy, then open TextPad, file/new, edit/paste. Then save the new file with the same name as the name of the class contained in it, capitalized in exactly the same way, and with the .java extension. 6. As a test of compiling and running a program, download the file Firstprog.java from my Web page and save it in the temp directory of the c: drive of the machine you’re working on. You may also try working off of a diskette or through a Web drive, but in any case it should work if you’ve saved the file in the temp directory. 7. Using TextPad, open the file Firstprog.java. Then click the Compile Java menu item. This will take several seconds. A successful compilation will simply end showing the program file on the screen. An unsuccessful compilation shows a new screen with the error messages for the compilation. This sample program contains no errors as given. If you get compiler errors, check to make sure you have correctly saved the file under the name of the class contained within it and with the .java extension, and then try compiling again. 8. After a successful compilation you can then take the Run Java Application option in the menu. This should bring up a DOS Window with the program output in it. 2 9. You can print program source files directly out of TextPad through the File option in the menu. The name of the printer in the lab is PRINTSRV/lpwin. If it hasn’t been already, it needs to be installed through Windows under your login in order to show up as an option when printing. 10. Depending on the version of Windows you have, you may be able to print output in more than one way. In any case you can print it as follows: Output will be contained in a DOS Window. Make sure that window is active by clicking on it. Press the 2 keys ALT+PRINT SCREEN to capture a copy of the window; then open MS Word, and do edit/paste into a new Word document. A copy of the whole DOS Window will appear in the document. You can make its contents black on white instead of white on black by using the mouse to highlight the DOS screen before capturing the copy if you want to. Java file naming, capitalization, and extensions: 1. Java program files have the extension .java. 2. The name of the file you save a program in (except for the extension) has to agree exactly (including capitalization) with the class name given at the top of the program (public class Program-name). 3. Java is case sensitive and java program files have to start with a capital letter. DOS and Windows don't make strong case distinctions, but the compiler will give errors unless the program file starts with a capital letter. Handing in and saving assignments: 1. Hand in printed copies of the program files you wrote plus printed copies of their output. Remember to save copies of the files on a diskette or somewhere else for future reference. Some programming assignments are cumulative. 2. When you hand in printed material you need to include at the top of each page the lab number, the program name (both for the source and the output), and your name. Feel free to hand write this information on the pages. If there is more than one page to the assignment you should staple or clip the pages together, in order, so that I don’t misplace them. 3. There may be problems with compiling and running files off of diskettes. In order to compile and run, you may have to save the source file in a folder on the hard drive, say c:\temp. If you do so, remember to also save a copy on your diskette to take with you when you go.