Java
DOS,
the old operating system that the first versions of Windows relied upon, can
still be accessed in newer versions of Windows. It is not really called DOS anymore,
but rather simply the command prompt. In
newer versions of Windows, as soon as you hit START, you have a text field that immediately appears and you can
type cmd
in there (see below).
Doing so will bring you to a window
that looks like this: NAVIGATING IN DOS PART 1 – THE cd..
COMMAND In the window above, you get a
listing of the folder (also known as directory) that you are currently in. Above, you see that you are on the C
drive, then inside the Users folder, and then inside the Administrator
folder. We can go up one level by using the cd..
command. Using the command twice
will bring us to the C drive (See below). PART 2 – THE dir
COMMAND To see a listing of files and
subfolders that are in the current folder, you simply type in dir. In the listing above, you see the
file names and folders on the right hand side. The <DIR> specifies that those
are folders (directories). PART 3 – THE cd dirName COMMAND We can go into a subfolder by also
using the cd command. In this case, we simply add the folder’s
name. With these commands, you should now
be able to go to any folder on any drive on your computer. GOING TO JAVA’S FOLDER We need to go to the folder that
contains Java. To do this, we use
the following commands: cd C:\ <hit enter> cd Java <hit enter> We can now see what is inside this
folder using the dir command. You can see that there one folder
with JDK1.7 and three different folders with JRE software. This will vary on different
computers. To run a program, we will go inside
the JDK folder. We have to type
that exactly. cd jdk1.7.0_13 We now want to go inside the bin
folder. cd bin We are now in the folder that
contains both the java compiler and the java interpreter! Woo hoo! LOCATING/CREATING YOUR JAVA FILE OPTION
1 OPTION
2 In Notepad, type your program. Make sure the class name matches the
file name. Save it. COMPILING YOUR FILE Simply type javac
Test.java RUNNING YOUR APPLICATION Simply type java Test In the example above, the filename is called
PATTEST.java |