Below are the steps outlined below to save, compile, and run your Java program.
Saving a Java Program
You can use any editor or word processing program to create and edit a Java program, as long as it can save files in ASCII format. Java programs must be saved in a file whose name ends with the.java
extension, so using your favorite ASCII editor and save the program to a file namedDateApp.java
.
Compiling a Java Program
The Java compiler translates Java source code into Java bytecodeswhich are components of a machine-level language for the Java virtual machine. Java bytecodes are interpreted and executed by the Java interpreter.
When you compile a Java source file, the compiler creates a file with the.class
extension in the same folder as the source file. The compiler names the resulting.class
file after the class defined in the source file. For example, when you compile theDateApp
class you created above, the compiler names the resulting class fileDateApp.class
after the class, regardless of the name of the source file. Even if you were to save theDateApp
class to a source file namedWow.java
, the compiler would still create a file namedDateApp.class
. By convention, to alleviate confusion, Java source files are named for the class defined within.
No comments:
Post a Comment