安装JDK8
1. 打开https://www.oracle.com/java/technologies/javase-downloads.html页面,点击下载链接后,选择jdk-8u251-linux-x64.tar.gz;
2. 解压缩到指定目录
# 创建目录 sudo mkdir /usr/lib/jvm
# 解压至上述目录 sudo tar -zxvf jdk-8u251-linux-x64.tar.gz -C /usr/lib/jvm
3. 修改环境变量
# 打开.bashrc文件 sudo gedit ~/.bashrc
# 在文件末尾换行追加下面内容,设置JAVA环境变量
export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_251
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
# 生效
source ~/.bashrc
4. 向系统注册java命令
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.8.0_251/bin/java 300
5. 验证
java -version
6. 多版本JDK切换
sudo update-alternatives –config java
注释
1. .bashrc
The purpose of a .bashrc file is to provide a place where you can set up variables, functions, and aliases, define your (PS1) prompt, and define other settings that you want to use every time you open a new terminal window. It works by being run each time you open up a new terminal, window or pane.
安装Python2.7
# python安装 sudo apt-get install python2.7 # pip安装 sudo apt install python-pip # 验证 python
————————————————
参考文献
1. 版权声明:本文为CSDN博主「世界需要爱和和平」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_41836744/article/details/89737978(部分修改)
2. 版权声明:本文为CSDN博主「软测小生」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/zbj18314469395/article/details/86064849
3. https://unix.stackexchange.com/a/129283