0x01 Java learning record - development environment
Development environment
This section describes how to build a Java development environment in Windows, Linux, MacOS and other platforms
Windows
plan 1
- Download Oracle JDK
- Java SE Development Kit 8 Downloads
- Java SE Development Kit 8 selection
- Windows x64 accept the agreement, and then download jdk-8u171-windows-x64.exe
- Install Oracle JDK
double-click jdk-8u171-windows-x64.exe and installed in accordance with the corresponding prompts, at the same time you can specify the installation location, the default installation location of the parent directory: C: \ Program Files \ Java - Configuration environment variable
- Computer -> right click and select Properties -> Advanced System Settings -> Environment Variables
- A mode: system environment variable manner
the new system JAVA_HOME environment variable and its value set JDK installation directory
increase% JAVA_HOME% \ bin before the system PATH environment variable value;
- Second way: personal environmental variable manner
new personal JAVA_HOME environment variable and its value set JDK installation directory
new personal PATH environment variable and set its value% JAVA_HOME% \ bin;
- A mode: system environment variable manner
- Computer -> right click and select Properties -> Advanced System Settings -> Environment Variables
- Check the Oracle JDK
The default JDK version check command
java -version javac -version
Find Java location
which java
- He added that
because Oracle JDK download Oracle now need to register an account, you can choose OpenJDK release AdoptOpenJDK be used instead.
Linux
plan 1
- Download Oracle JDK
- Java SE Development Kit 8 Downloads
- Java SE Development Kit 8 selection
- Linux x64 accept the agreement, and then download jdk-8u172-linux-x64.tar.gz
- Install Oracle JDK
decompression jdk-8u172-linux-x64.tar.gz to specify the installation location, the default installation location of the parent directory: / usr / lib / jvm / Configuration environment variable
to add the following content in the user's home directory .bashrc file and execute source ~ / .bashrc toexport JAVA_HOME=/usr/lib/jvm/jdk1.8.0_171 export PATH=${JAVA_HOME}/bin:$PATH
- Check the Oracle JDK
The default JDK version check command
java -version javac -version
He added that
because Oracle JDK download Oracle now need to register an account, you can choose OpenJDK release AdoptOpenJDK be used instead.
MacOS
plan 1
- Download Oracle JDK
- Java SE Development Kit 8 Downloads
- Java SE Development Kit 8 selection
- Mac OS X x64 accept the agreement, and then download jdk-8u171-macosx-x64.dmg
- Install Oracle JDK
double-click jdk-8u171-macosx-x64.dmg and installed in accordance with the corresponding prompt, the default installation location of the parent directory: / Library / Java / JavaVirtualMachines / - Configuration environment variable
A way
to add the following in the user's home directory and execute the .bash_profile file content source ~ / .bash_profile toexport JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home"
Second way
to add the following content in the user's home directory and execute the .bash_profile source ~ / .bash_profile toexport JAVA_HOME=$(/usr/libexec/java_home)
- Check the installation
The default JDK version check command
java -version javac -version
The default Java installation location check command
/usr/libexec/java_home
Temporary specified Java version
/usr/libexec/java_home -v 1.8.0_171 --exec javac -version
Scenario 2
Installation by brew
brew tap caskroom/versions
brew cask install java8