linux安装jdk wget
时间: 2023-09-21 09:12:27 浏览: 154
在Linux中安装JDK可以使用wget命令。首先,使用wget命令下载JDK安装包。你可以通过以下命令下载JDK安装包:
```
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.rpm
```
然后,给下载的安装包添加执行权限:
```
chmod 755 jdk-8u131-linux-x64.rpm
```
接下来,执行rpm命令进行安装:
```
rpm -ivh jdk-8u131-linux-x64.rpm
```
安装完成后,可以使用以下命令检查是否安装成功:
```
java -version
```
为了将JDK配置到系统的环境变量中,你需要编辑`/etc/profile`文件:
```
vim /etc/profile
```
在文件的最后,追加以下内容:
```
export JAVA_HOME=/usr/java/jdk1.8.0_131
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$JAVA_HOME/bin:$PATH
```
添加完成后,保存退出,并立即刷新环境变量,使修改立即生效:
```
source /etc/profile
```
最后,你可以编写一个main方法输出一条语句,如果能正常输出,则说明JDK的安装和环境搭建已完成。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [linux安装jdk](https://blog.csdn.net/weixin_43928236/article/details/129031746)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [Linux下使用wget安装JDK](https://blog.csdn.net/weixin_44386705/article/details/123318794)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文