Running Applications from the Command Line Flashcards

1
Q

To compile a program from the command line you need to use the
j_______ command to compile a source file and the
j_______ command to run the program.

A

javac
java

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Instructions

1) Write your program in the n________.

2) Save your program on the desktop.
You must use the class name, e.g. HelloWorld
followed by .java (this is the Java f____ e___________)

HelloWorld.java

3) Open Command Prompt, change the address to Desktop. So, type:
cd Desktop

4) To compile your program to b______ code type:
javac HelloWorld.Java

5) To run your program type:
java HelloWorld

A

notepad
file extension
byte

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Jar Files

JAR stands for J_____ AR_____

A JAR file has the extension .jar and is simply a c________________ file.

A JAR file is used for aggregating many files into one.

.Jar is the only format that handles audio and image files as well as c______ files

A

Jar ARchive
compressed file (like a zip Folder)
class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How to create JAR Files

Most IDEs provide a means of creating JAR files but JAR files can also be created from the c________ p__________ with the jar.exe tool.

A

command prompt

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Try and Catch

The ‘try’ statement allows you to define a block of code to be tested for errors while it is being e___________.

The catch statement allows you to define a block of code to be executed if an e______ occurs in the try block.

The try and catch keywords come in pairs:

A

executed
error

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Try and Catch

What happens to the program if try and catch, catches an error?

A

It will not shut down.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Try and Catch - Example of Catching an Exception

e.g.

try {
int myInt = Integer.parseInt(“pants”);
System.ou.println(myInt);
}
catch (NumberFormatException) {
System.out,println(“You can’t parse ‘pants’ as an integer!”)
}

Notice the ‘NumberFormatException’.

a) What type of exception will this catch?
b) Will it catch other types of exceptions?
C) What do we use to catch every type of exception?

A

a) A number format exception
b) No
c) Exception e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Try and Catch - Note

You only want to catch e____________, you don’t want to catch errors.
You will learn more about this later, but for now don’t ever:

catch (Exception t) XXXXXXXXXXXXXXXXXXXXXXX Wrong!!!!!

A

exceptions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly