![](https://img-blog.csdnimg.cn/img_convert/6b9fb7f0b4cf1fdfb17f7f1f8f6a72fc.png)
java编写到编译到运行
java. For installation guide read:
Java的 有关安装指南,请阅读: Java Installation: Downloading, Installing and Setting PathJava安装:下载,安装和设置路径
如何编写和运行Java程序? (How to write and run Java programs?)
- Open notepad and write below program. 打开记事本并编写以下程序。
static void main(String…S)
Programming”);
Now save the file with name demo.java on desktop. Here you can replace demo with any other name that you want.
现在,在桌面上将文件保存为demo.java 。 在这里,您可以将demo替换为所需的任何其他名称。
Then open command prompt (cmd) and type cd desktop and press enter to change current directory to desktop.
然后打开命令提示符(cmd)并键入cd桌面 ,然后按Enter键将当前目录更改为桌面。
We changed directory because our program is saved on desktop.
我们更改了目录,因为我们的程序保存在桌面上。
To compile java program type javac demo.java and hit enter. Type java demo to run the program. Remember that here we have to compile
要编译Java程序,请输入javac demo.java并按Enter。 键入java demo来运行程序。 请记住,这里我们必须进行编译
with program name and execute with class name that we have used in program. The
使用程序名称,并使用我们在程序中使用的类名称执行。 的
java program name and class name can be different.
java程序名称和类名称可以不同。
![compile and run compile and run](https://1.bp.blogspot.com/-YWaWiHBKrW0/U5DF8g_0OeI/AAAAAAAACYw/zDmfKWBS30Q/s1600/compile+and+run.jpg)
了解计划 (Understand the Program)
![Understand the Program Understand the Program](https://3.bp.blogspot.com/-RGYc9wV4wBY/U5DF8Qe9bLI/AAAAAAAACYo/7Im6MwU1z44/s1600/Understand+the+Program.jpg)
which program is running. Here the device is cmd.
哪个程序正在运行。 此处设备为cmd。
A.java
|
A.java
|
A.java
| |
class A
{
}
|
class A
{
public static void main()
{
}
}
| ||
compile
|
Yes
|
Yes
|
Yes
|
.class file
|
Not created
|
Created
|
Created
|
execute
|
No
|
No
|
Yes
|
A.java
|
A.java
|
A.java
| |
A级
{
}
|
A级
{
公共静态void main()
{
}
}
| ||
编译
|
是
|
是
|
是
|
.class文件
|
未建立
|
已建立
|
已建立
|
执行
|
没有
|
没有
|
是
|
翻译自: https://www.thecrazyprogrammer.com/2014/06/how-to-write-compile-and-run-your-first-java-program.html
java编写到编译到运行