Joke Collection Website - Joke collection - How to compile java

How to compile java

Compile a java program using a command prompt:

1. First, create a new text document and enter your own java program.

Here I write a simple java program to demonstrate.

Import java.util. *;

Public class HelloDate {

Public static void main(String[] args)

{

System.out.println ("Hello, yes");

system . out . println(new Date());

}

}

2. Then save it as a java file.

1. select the file-> save as-> with the name "hello.java"->; Select all files.

2. Remember the storage location of this file. (Easy to talk! )

3. open the program-> attachments-> command prompt.

4. Because my java text is saved under F:/java/ (in the java folder under F drive), if you want to compile, you need to enter the java folder through the command prompt first. The specific steps are as follows:

1. Enter disk f: Enter f: and press Enter.

2. enter cd java and press enter.

This has entered. The cd here means to enter.

5. Then call the java compiler to compile.

Enter javac HelloDate. Java, and then press enter.

Then run the results.

Type java HelloDate, and then press Enter.

Experience summary: The general process of running a java program is:

Write source code-> compile-> run-> end.

Precautions:

1. Please be case-sensitive when entering.

Please make sure that your computer is configured with java running environment before operation.