I have had time recently to write some simple and basic things, mainly at the operational level. The main considerations are as follows: 1. Build a development environment frequently, so it is necessary to record it and you can also check it yourself; 2. Show it for beginners and write some of the simplest and most practical things.
1. Confirm that Java has not been installed
First, make sure that Java is not installed on our computer. Open the command line and enter java -version . When you see the following display, it means that Java has not been installed yet.
2. I haven't installed it in Java. Download the latest Java version on the official website.
Next, go to Oracle's website to download the latest Java version. Search the keyword "oradle java" on Baidu to find it easily. It is not recommended to use other people’s downloaded software directly, or to download it from third-party websites. It is only recommended to download these open source software on official websites.
The following are the main steps, not complete and not unique, so you don’t have to follow my steps very strictly.
You must select "Accept License Agreement" here to allow downloading. What I'm down is "jdk-8u45-windows-x64.exe".
3. After downloading, click Install
Then the next step and the next step are all ready. Note: It is recommended that the path to install the software should not contain Chinese, spaces and special characters. Don't put the software in a deep path. If it is a Windows operating system, don't put the software on the C drive (because if the system is reinstalled, these software will disappear. Some software, such as Java we are talking about now, do not need to be reinstalled, just configure the environment variables and path).
I am used to creating a new folder under the non-C drive letter, such as "D:/app" as the directory for all my installation and development software. Of course, it is called "dev" or "tools" I think are both good choices.
Then there is the next step, the next step.
The following configuration is very critical.
4. Configure JAVA_HOME and path environment variables
After installation, the directory will look like this.
Note: We will not need to operate the above steps in the future. Even if you package and copy these files to another computer with JAVA_HOME and path configured, it can be used.
Right-click on "My Computer" and click Properties
Select Advanced System Settings
Click Environment Variables in the Advanced tab
Create a new item in the user variable of "Administrator". The variable name is JAVA_HOME and the variable value is the Java software home directory that you just installed.
For example:
Create a new item in the user variable of "Administrator". The variable name is path and the variable value is as follows
Variable name: path
Variable value : %JAVA_HOME%/bin;
Among them, the variable surrounded by "%" refers to the Java installation file home directory that the variable name JAVA_HOME in the previous step actually points to.
This completes the separation of variables, which facilitates our future modifications. If you want to change the Java installation directory, first move the installation directory, then modify JAVA_HOME and change it to the corresponding computer installation directory. Many of our software are installed like this. Isn’t it very green and environmentally friendly?
Key point: The significance of configuring path environment variables
When we enter java-related commands in the cmd command window, our operating system will search for java programs in the current path by default, which is the following program. That is, when we run the java -version command, we actually run the program marked in the figure below:
But many times
1. We want to compile a java source code. We cannot position cmd to the bin directory installed by Java software every time, which increases the complexity of our compilation of source code;
2. Many software requires the support of Java software to run, such as Tomcat, Ant, Maven, Gradle, development tools Eclipse and IntelliJ IDEA, etc. How do they realize that Java programs are installed on our computer?
So we need to configure path, and the operating system stipulates this:
1. When running the program, in addition to searching for the program in the current directory, it also returns to the path pointed to by the environment variable path. If it is found, it can run smoothly. Path can be set multiple paths, separated by English semicolons;
2. Tomcat, Ant, Maven, Gradle, development tools Eclipse and IntelliJ IDEA will also go to the path pointed to by the environment variable path to find if there is Java. If so, you will feel that Java software is installed on the machine.
Verify that the installation is successful
At this point, the Java software is installed, and we enter it in the cmd window
java -version
As shown in the figure below, it means that the Java installation has been successful.
Tips
Hold down the shift key with your left hand and right mouse button. You will see "Open command window here", which can quickly locate the cmd window to the specified directory.
The above is all the content of this article. I hope it will be helpful to everyone's learning and I hope everyone will support Wulin.com more.