Monday, December 6, 2010

Examples

To create a directory named Taxes with a subdirectory named Property, which contains a subdirectory named Current, type:

mkdir \Taxes\Property\Current

This is the same as typing the following sequence of commands with command extensions disabled:

mkdir \Taxes
chdir \Taxes
mkdir Property
chdir Property
mkdir Current

Essential Commands

dir

Lists names of files in current directory (folder)

dir Hello.*

Lists all files whose names start with Hello.

cd C:\files

Changes directory to C:\files ("absolute" pathname)

cd myfiles

Changes directory to myfiles subdirectory of current directory ("relative" pathname)

cd ..

Changes directory to "parent" of current directory

notepad Hello.java

MS-DOS text editor, used to create and edit ASCII textfiles

type Hello.java

Displays contents of ASCII textfile on screen

exit

Ends command interpreter, makes console window go away...

Useful File Management Commands

copy Test1.java Test2.java

Copies contents of Test1.java to new file Test2.java

ren Test1.java Test2.java

Renames Test1.java to Test2.java

del Test1.java

Deletes Test1.java (Be careful with this command...)

del Test1.*

Deletes all files with Test1 prefix (Be even more careful with this command...)

mkdir playpen

Creates new directory playpen as subdirectory of current directory

rmdir playpen

Removes directory playpen (must be empty)

Commands for Compiling and Running Java Applications

Note: if the commands in this table are not recognized by the MS-DOS command interpreter on your system, try using the path commands listed below...

javac Hello.java

Compiles Java source file Hello.java (ASCII textfile),
produces bytecode file Hello.class (binary file)

java Hello

"Runs" Java application: starts Java Virtual Machine (interpreter),
which executes Java bytecode instructions in file Hello.class

Using javadoc to Document Java Classes

Note: if the commands in this table are not recognized by the MS-DOS command interpreter on your system, try using the path commands listed below...

javadoc Cat

Generates Web document Cat.html, containing description of Cat class. Complete documentation requires inclusion of javadoc comments (/** .. */) in source code.

Jar (Java Archive) Commands

Note: if the commands in this table are not recognized by the MS-DOS command interpreter on your system, try using the path commands listed below...

jar cf Pets.jar Pets

Creates Pets.jar, containing compressed version of Pets folder and all its contents

jar tf Pets.jar

Displays list of zipped files in Pets.jar

jar xf Pets.jar

Extracts (unzips) entire contents of Pets.jar, preserving any directory structures

Useful FTP Commands

ftp ftp.cs.unca.edu

Attempts to start anonymous FTP session on remote Computer Science server. Enter ftp for userid and your bulldog email address for password.
Note: Before attempting to upload files, remember to cd to appropriate dropoff directory as shown below.

ftp candler.cs.unca.edu

Attempts to start FTP session on remote Computer Science server candler.cs.unca.edu. You will need to provide your CSCI userid and password for this host.
Note: This command connects you to your own home directory, not the site used for making dropoffs.

ftp> ascii

FTP command to set data transfer mode to ASCII (default, suitable for .java source files and other textfiles)

ftp> binary

FTP command to set data transfer mode to binary (suitable for .class files and other binary files)

ftp> status

FTP command to display status, including current data transfer mode (ASCII or binary)

ftp> cd pub/202/fred1234

FTP command to change current directory on remote host

ftp> lcd C:\files

FTP command to change current directory on local system

ftp> put Hello.java

FTP command to copy file Hello.java from current directory on local system to current directory on remote host

ftp> mput *.java

FTP command to copy all files ending with .java from current directory on local system to current directory on remote host

ftp> quit

FTP command to end session, breaks contact with remote host

Энийг уншив: жиргэе!

No comments:

Post a Comment