103k views
3 votes
Suppose you are at an operating system command line, and you are going to use the following command to compile a program:javac MyClass.java Before entering the command, you must:

What must you do before entering the command?
A) Save the program as "MyClass.java"
B) Install the Java Development Kit (JDK)
C) Navigate to the directory containing "MyClass.java"
D) Open a text editor to write the program

1 Answer

4 votes

Final answer:

Before compiling a Java program with the command 'javac MyClass.java', ensure the Java Development Kit (JDK) is installed on your system, navigate to the directory that contains 'MyClass.java', and have the file already written and saved with the proper name.

Step-by-step explanation:

Before entering the command javac MyClass.java at the operating system command line to compile a program, several steps must be ensured for the process to be successful. Firstly, you must ensure that you have the Java Development Kit (JDK) installed on your system as it contains the javac compiler needed to compile Java programs. Without the JDK, the javac command would not be recognized. Secondly, you should navigate to the directory containing the Java source file, in this case, "MyClass.java".

This means you use the command line to change the current working directory to the one where your file is located. Lastly, the program code should already have been written and saved as "MyClass.java" using a text editor or an Integrated Development Environment (IDE) before you attempt to compile it.

User Rytis
by
8.0k points