Java Reference
In-Depth Information
Once this is done, open a command-line window (start cmd.exe on Windows) and navigate to your
Desktop folder. Usually, typing cd %HOMEPATH%\Desktop does the trick, but if not, navigate to
your Desktop folder by using a combination of cd .. and cd foldername commands, as shown in
Figure 8-6.
fiGure 8-6  
Next, on the command-line, start your Java program using the command java -jar liner-
everser.jar . The program will start and you will be able to interact with it just as you did from
Eclipse's console. See Figure 8-7.
fiGure 8-7
Note how both the standard output and standard error streams are shown on the command-line
by default. However, we can perform a neat little trick now by what is called “stream redirection.”
Let's say we want to save our reversed lines to a text file, but we do not want to save the error mes-
sages. In this case, we can execute the following command: java -jar linereverser.jar > out-
put.txt . See Figure 8-8.
fiGure 8-8
Search WWH ::




Custom Search