As a front-end, its core competitiveness is far less than that of the back-end, so learn the back-end to improve your own level. This series of articles will learn the backend from a frontend perspective.
What is JDK, JRE, JVM
To learn java, we first need to understand what is JDK , JRE, and JVM.
name | paraphrase |
---|---|
JDK | is a complete development environment including the JRE and tools used by developers |
JRE | It is the runtime environment of the Java program, including the core class library required by the JVM and runtime |
JVM | JVM is the abbreviation of Java Virtual Machine, which is the execution environment of Java application program runtime. |
Simply put, as a developer, our computer can install JDK
Download and install JDK
To learn java, we must first download and install JDK . We can find the installation package on the official website, download URL (Oracle official website): www.oracle.com
Note: This tutorial installs java17
After downloading the installation package, we can double-click the fool-proof installation
The following interface appears, click Close
After installation, we open the cmd command line in the installation directory, enter the bin directory, enter javac and there will be a prompt
A prompt appears, which means that our program is successfully installed
Configure the path environment variable
It should be noted that if we are using the java8 version, when we enter the javac command in the non-jdk installation directory, the following prompt will appear
At this point, we need to configure the environment path environment variable.
java17版本已经帮我们配好了,所以不用再配置环境变量。
development tools
There are many java development tools, such as
Text and Development Tools | |
---|---|
notepad++ | |
sublime | |
Integrated Development Environment | |
IDEA | |
eclipse |
IDEA is used more , which is similar to the front-end vscode . Of course, we can choose sublime without code hints as the tool to start learning.
Java program development process
Like the front-end TS, files with a java suffix cannot be run directly. They need to be compiled into bytecode files before they can be run. Its general development process is as follows:
- 将 Java 代码编写到扩展名为 .java 的源文件中
- 通过 javac.exe 命令对该 java 文件进行编译,生成一个或多个字节码文件
- 通过 java.exe 命令对生成的 class 文件进行运行
Let's create a hello.java file first, and then use Notepad to open and write the sample code
Then, we enter javac hello.java in the console to compile the code, and after the code is compiled, there will be an extra hello.class byte-encoded file
Finally, we can use the java command to run the byte-encoded file
java helloChina
Such a development process is very cumbersome, and every time the code is written, it must be manually compiled. Therefore, in actual development, we can use IDEA software, which integrates all environments and saves us the step of compiling the code.
Idea installation and use
Using Notepad to develop java requires manual compilation, which is very troublesome. We can use the compiler IDEA to save me these tedious steps.
IDEA can go to the official website to download, and then install it foolishly
After the installation is complete and activated, we click NewProject, and then perform some simple configurations
After the configuration is complete, you can enter the project