Using Flags In Java Command Line - extension. Executing: To...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Using Flags In Java Command Line When using command line (Linux:Terminal, Windows:Command Prompt…) to compile and run your program you need to know a few basics. Navigating: On Windows: You can type “dir” anytime to see the contents of the current directory. When you know where you are, type “cd (folderName)” to change directories. Ex. “cd Desktop” If you need to go up a folder use “cd . .” command. On Linux: You can type “ls” anytime to see the contents of the current directory. When you know where you are, type “cd (folderName)” to change directories. Ex. “cd cs1332” // Moves to a “cs1332” folder If you need to go up a folder use “cd . .” command. Using Java VM: Compiling: To compile a java file, you use “javac” (java compiler) in a command like “javac HelloWorld.java”. If compiled correctly, you will see nothing and the prompt will drop to the next line. If there were errors, they are displayed. You can also use “javac *.java” to compile every file in the current directory with the .java
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: extension. Executing: To run a java file use “java HelloWorld”. Notice there is no “.java” extension on the end of the filename. This command tells the Java VM to execute the “HelloWorld.class” file. Flags… Flags: Flags are parameters passed into a “public static void main(String args)” method. If I choose to add flags (parameters) to a program I type each of them after the execution call. After making this call inside out “public static void main(String args)” method, we will have an args array that contains: 0 “fName” 1 “mName” 2 “lName” 3 “-Jr” This is done similar to a “java DisplayName fName mName lName”.split(“ “); command which will split the string up at each space character and insert the resulting words into an array. Command line does the same thing but drops the “java FileName” part of the string before constructing the args array. javac DisplayName.java java DisplayName fName mName lName -Jr...
View Full Document

This note was uploaded on 05/23/2011 for the course COMPUTER S 1332 taught by Professor Sweat,monica during the Fall '10 term at Georgia Institute of Technology.

Page1 / 2

Using Flags In Java Command Line - extension. Executing: To...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online