Saturday, August 12, 2017
Command Line
The command line supports some practical abbreviations to refer to important directories(console command):
"." It is shorthand for our working directory.
".." it is shorthand for the parent directory of your working directory
In the following example we will move the java file that we copied earlier, the directory E:\backupto the directory using the command MOVE.
Working with files
In the above examples we have seen how to list files in a directory, copying files and how to move them. Then a little more extensive list is presented useful commands to work with files:
CD Changes the working directory
Command Line supports some wildcard, used to refer to several files simultaneously. For example the character "*" is used to refer to all files in a directory.
For example, to copy our files to our USB skewer practices, we can use the following command:
Working with Java
To work with Java, at a basic level, it is important to know the following commands(console command 2017):
JAVAC: The Java compiler. It accepts as arguments a list of files .javayou want to compile. Also supports other arguments, the full list can be obtained by running the command without arguments.
JAVA: The Java virtual machine. It accepts as an argument the name of the class whose method Mainis to be executed. Also supports other arguments, the full list can be obtained by running the command without arguments.
In the following example we will compile and run a simple Java program from the command line:
Redirect input / output
Commands designed to work with the Command Line have default 3 interfaces communication with the outside world:
standard input: It is a data flow that programs can read to get their input. Default is associated with the keyboard. For example, the command line itself finds out that the user wants to run commands watching standard input, ie keys the user presses.
stdout: It is a data stream by which programs can show results. Default is associated with the text that shows the command line. When our HelloWorld Java program uses System.out.println("Hello World!")is asking the standard output to display the text on the screen.
stderr: Similar to standard output but to show error messages rather than results.
These flows can be redirected for example to save the result of a command to a file rather than the screen display, or to redirect the output of a command to the input of another command.
For example, to save the output of our HelloWorld program in a file called salida.txtand check its contents later, we can run the following script(console command pc):
If we have a Java program that has standard input words, we can count the words of our file as follows:
Limitations of the Command Line
In many operating systems, the command line is an extremely powerful and versatile program, whose professional management is essential for efficient performance of our work.
However, the Windows command line is a special case because its functionality is very limited, their language is inconsistent and documentation is sparse and confusing.
Even so, learn to use it is very beneficial because not only it will save time when working in Windows, if not that familiar with a tool that we need in the future, in other more professional environments.
Exercises for the reader
Find out how to copy and paste long texts and from the command line (for example to copy an error message from the Java compiler from the command line in a Web browser so you can find whatever that means).
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment