Java & J2EE Page 3 - Java Beginning Programming |
To start, you will need to create a source file. Left-click on your Start menu and choose All Programs>Accessories>Notepad. When your document opens, type the following code: Note: All code is case-sensitive, so be sure to type it in exactly as you see it. /* class GoodbyeCruelWorldApp { Save the notepad file to your C: drive (it typically does not matter where you store the file. But in this case we will use your C: drive) under the name Next we must change your source file into a .class File. To do this, left-click on your Start menu and choose the Run command. Type cmd into the pop-up box and press Enter. This will load the Command window, shown below:
In order to compile your Source File, you must change the directory to where your file is located. In the above example the prompt is set to your C: Drive. To change the directory, type cd C: and press Enter. Next, to display the files within your C: Drive, type dir You are now able to compile. In the prompt line type javac GoodbyeCruelWorldApp.java and press Enter. If you type in dir again, you will see the new file, GoodbyeCruelWorldApp.class. You are now ready to run your first program! Running Your First Program Without changing your directory, type java GoodbyeCruelWorldApp at the prompt. This should display the text: “GoodbyeCruelWorld!” in the prompt window.
blog comments powered by Disqus |