[2] Java operation mode, program structure and notepad++

Fu Xiaojian 2022-08-06 16:26:08 阅读数:921


携手创作,共同成长!这是我参与「掘金日新计划 · 8 月更文挑战」的第5天,点击查看活动详情


in the first lecture,进行了Java环境的搭建,Wrote the first through a text documentJava文件并成功运行.

This talk is mainly correctJavaThe operation mode and structure of the program are introduced,And introduce the convenient editor software.



The compiler compiles source files:如果.java文件没有错误(For example lexical errors、语法错误),就会产生.class文件.The compiled file is composed of bytecode.

Java虚拟机(JVM)运行.class文件:JVM会将字节码转换成平台能够理解的形式来运行.class文件,Get or output the corresponding result.当JVMWhen starting the executor,will look for the specified class,located in the classmain方法,接着执行maineach instruction in the method.


There are classes in the source files,method in the class,There are specific implementations in the method.

The following code is a basic oneJava文件结构.main函数是程序的入口

public class FirstCode{
pulic static void main(String[] args){


In the first lecture we wrote one using a text documentJava程序,But it would be extremely inconvenient to always use text documents,For example, automatic indentation is not possible、There is no way to tell where the code is written to go wrong、Whether the curly braces of the program are missing,So we need a suitable editor to write programs.

在学习Java初期,Mainly by typing some relatively simple code,run and get the output,No interaction with others is required,Therefore, it is not used for the time beingIDEA、eclipse等集成开发环境,All you need is a simple editor.

Here I recommend two editors:atom和notepad++



atomIt is an editor that can highlight code,And provides a code supplement mode,It is an advanced form of text document,Running the program also needs to be in the form of the command line,Compile the file first,之后再运行.

The software can be downloaded directly from GitHub上获取github.com/atom/atom在这里插入图片描述


notepad++可以在这里编写Java程序,并进行编译运行,It is no longer necessary to execute programs in command line form.

  1. First select from LanguagesJava 在这里插入图片描述

  2. Write a code program in the editing area and save it as .java文件 在这里插入图片描述

  3. select macrojavac进行编译程序(或使用快捷键ctrl+1) 在这里插入图片描述在这里插入图片描述

  4. 编译没有问题后,选择java(或快捷键ctrl+2)运行程序 在这里插入图片描述

copyright:author[Fu Xiaojian],Please bring the original link to reprint, thank you. https://en.javamana.com/2022/218/202208061615500254.html