Set up Java development environment under Linux system
- 2020-04-01 03:30:04
- OfStack
A, download
The first, of course, is to download.
Address: (link: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html)
Select different versions as needed.
Second, the decompression
Unzip the downloaded.tar.gz file.
Unzip using the following command:
sudo tar zxvf ./jdk-7u45-linux-x64.tar.gz
To facilitate administration, you can move the unzipped files to another folder.
Don't do it.
I moved the file to /opt/Java/ JDK/directory.
To facilitate the next step of setting the environment variables, the folder was changed to a shorter name - jdk1.7
You can rename the folder using the following command
sudo mv jdk1.7.0_45/ jdk1.7/
Set environment variables
Edit the.bashrc file.
Enter the following command at the terminal:
vi ~/.bashrc
At the end of the file, add the following lines:
export JAVA_HOME=/opt/Java/jdk/jdk1.7
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
For the changes to take effect immediately, execute the following command at the terminal:
source ~/.bashrc
PS: when there is an error in modifying the PATH of ~ /.bashrc, other commands of the system cannot be used
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/games
P.S. before modifying the.bashrc file, it is best to backup the command:
Cp. Bashrc. Bash_origina