首页 > 其他分享 >安装JDK

安装JDK

时间:2023-06-14 17:46:43浏览次数:45  
标签:java JDK jdk 安装 HOME root centos8

rpm安装 #需要登录下载:https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html

[root@centos8 ~]#ls -lh jdk-8u241-linux-x64.rpm
-rw-r--r-- 1 root root 171M Feb  8 18:29 jdk-8u241-linux-x64.rpm
#安装jdk,无相关依赖包 [root@centos8 ~]#dnf -y install jdk-8u241-linux-x64.rpm [root@centos8 ~]#java -version java version "1.8.0_241" Java(TM) SE Runtime Environment (build 1.8.0_241-b07) Java HotSpot(TM) 64-Bit Server VM (build 25.241-b07, mixed mode) #初始化环境变量 [root@centos8 ~]#vim /etc/profile.d/jdk.sh [root@centos8 ~]#cat /etc/profile.d/jdk.sh export JAVA_HOME=/usr/java/default export PATH=$JAVA_HOME/bin:$PATH #以下两项非必须项
  export JRE_HOME=$JAVA_HOME/jre   export CLASSPATH=$JAVA_HOME/lib/:$JRE_HOME/lib/

  [root@centos8 ~]#. /etc/profile.d/jdk.sh   #运行

 

二进制文件安装
[root@centos8 ~]#tar xvf jdk-8u241-linux-x64.tar.gz -C /usr/local/
[root@centos8 ~]#cd /usr/local/
[root@centos8 ~]#ln -s jdk1.8.0_241/ jdk
#初始化环境变量
[root@centos8 ~]#vim /etc/profile.d/jdk.sh
[root@centos8 ~]#cat /etc/profile.d/jdk.sh 
export JAVA_HOME=/usr/local/jdk
export PATH=$PATH:$JAVA_HOME/bin
#以下两项非必须项
#export JRE_HOME=$JAVA_HOME/jre 
#export CLASSPATH=.:$JAVA_HOME/lib/:$JRE_HOME/lib/
[root@centos8 ~]#. /etc/profile.d/jdk.sh
#注意:JAVA_HOME变量必须设置,否则tomcat启动时会出下面错误
[root@centos8 ~]#catalina.sh
Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
At least one of these environment variable is needed to run this program
[root@centos8 ~]#startup.sh 
Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
At least one of these environment variable is needed to run this program

#验证安装
[root@centos8 ~]#java -version
java version "1.8.0_241"
Java(TM) SE Runtime Environment (build 1.8.0_241-b07)
Java HotSpot(TM) 64-Bit Server VM (build 25.241-b07, mixed mode)
[root@centos8 ~]#which java
/usr/local/jdk/bin/java

 

一键安装二进制的JDK
[root@ubuntu1804 ~]#vim install_jdk.sh
JDK_FILE="jdk-11.0.15.1_linux-x64_bin.tar.gz"
#JDK_FILE="jdk-11.0.12_linux-x64_bin.tar.gz"
#JDK_FILE="jdk-8u301-linux-x64.tar.gz"
JDK_DIR="/usr/local" DIR=`pwd` color () { RES_COL=60 MOVE_TO_COL="echo -en \\033[${RES_COL}G" SETCOLOR_SUCCESS="echo -en \\033[1;32m" SETCOLOR_FAILURE="echo -en \\033[1;31m" SETCOLOR_WARNING="echo -en \\033[1;33m" SETCOLOR_NORMAL="echo -en \E[0m" echo -n "$2" && $MOVE_TO_COL echo -n "[" if [ $1 = "success" -o $1 = "0" ] ;then ${SETCOLOR_SUCCESS} echo -n $" OK " elif [ $1 = "failure" -o $1 = "1" ] ;then ${SETCOLOR_FAILURE} echo -n $"FAILED" else ${SETCOLOR_WARNING} echo -n $"WARNING" fi ${SETCOLOR_NORMAL} echo -n "]" echo } install_jdk(){ if ! [ -f "$DIR/$JDK_FILE" ];then color 1 "$JDK_FILE 文件不存在" exit; elif [ -d $JDK_DIR/jdk ];then color 1 "JDK 已经安装" exit else [ -d "$JDK_DIR" ] || mkdir -pv $JDK_DIR fi tar xvf $DIR/$JDK_FILE -C $JDK_DIR cd $JDK_DIR && ln -s jdk* jdk cat > /etc/profile.d/jdk.sh <<EOF export JAVA_HOME=$JDK_DIR/jdk export PATH=\$PATH:\$JAVA_HOME/bin #export JRE_HOME=\$JAVA_HOME/jre #export CLASSPATH=.:\$JAVA_HOME/lib/:\$JRE_HOME/lib/ EOF . /etc/profile.d/jdk.sh java -version && color 0 "JDK 安装完成" || { color 1 "JDK 安装失败" ; exit; } } install_jdk

 

安装openjdk

yum install java-11-openjdk
yum install java-1.6.0-openjdk
yum install java-1.7.0-openjdk
yum install java-1.8.0-openjdk

 

TRANSLATE with x English
Arabic Hebrew Polish
Bulgarian Hindi Portuguese
Catalan Hmong Daw Romanian
Chinese Simplified Hungarian Russian
Chinese Traditional Indonesian Slovak
Czech Italian Slovenian
Danish Japanese Spanish
Dutch Klingon Swedish
English Korean Thai
Estonian Latvian Turkish
Finnish Lithuanian Ukrainian
French Malay Urdu
German Maltese Vietnamese
Greek Norwegian Welsh
Haitian Creole Persian  
  TRANSLATE with COPY THE URL BELOW Back EMBED THE SNIPPET BELOW IN YOUR SITE Enable collaborative features and customize widget: Bing Webmaster Portal Back

标签:java,JDK,jdk,安装,HOME,root,centos8
From: https://www.cnblogs.com/qude/p/17480929.html

相关文章

  • docker的安装
    1.安装gcc,gcc-c++,yum-utils,由于蜜蜂已经安装过了,这里显示已是最新版[root@bee~]#yuminstall-ygccgcc-c++yum-utils2.指定镜像仓库(其实就是配置几个yum)[root@bee~]#yum-config-manager--add-repohttp://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo3.......
  • yarn 安装进行时,显现错误 node_modules\gifsicle: Command failed.
    1.错误显示[4/5]Buildingfreshpackages...[7/13]⠠jpegtran-bin[6/13]⠠gifsicle[8/13]⠠mozjpeg[4/13]⠠gifsicleerrorE:\IdeaStudyProjects\ucthings-ui-vue\node_modules\gifsicle:Commandfailed.Exitcode:1Command:nodelib/install.jsArguments:D......
  • Scala简介和安装
    简介Scala是一种多范式的编程语言(多范式:多种编程方法的意思。有面向过程、面向对象、泛型、函数式四种程序设计方法),其设计的初衷是要集成面向对象编程和函数式编程的各种特性。Scala运行于Java平台(Java虚拟机),并兼容现有的Java程序官网:https://www.scala-lang.org/Scala以一种......
  • Ubuntu 源代码编译安装 Nginx
    建立nginx用户和用户组sudogroupaddnginxsudouseraddnginx-gnginx-s/sbin/nologin-M在线安装依赖sudoapt-yinstallgccmakeopenssllibssl-devlibpcre3libpcre3-devlibgd-devvimwgetnet-tools下载并解压nginx源代码wgethttp://nginx.org/download/nginx-1.24......
  • 安装elasticsearch集群开启认证
    ##节点:172.30.1.101172.30.1.131172.30.1.102##下载rpmwgethttps://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.12.0-x86_64.rpm#安装elasticsearch##设置环境rpm-ivhelasticsearch-7.12.0-x86_64.rpm##禁用swapswapoff-ased-ri's/......
  • docker 安装mysql-server
    ################查找mysql-server镜像:dockersearchmysql-server[root@igoodful~]#dockersearchmysql-serverINDEXNAMEDESCRIPTIONSTARSOFFICIALAUTOMATEDdocker.iodock......
  • MySQL基础:安装和启动
    MySQL基础:安装和启动课程安排基础篇介绍数据库相关概念SQL是操作关系型数据库的编程语言主流关系型数据库总结安装MySQL数据库MySQL数据库启动与停止默认mysql开机启动客户端连接方式1方式2需要配置环境变量......
  • 如何在Ubuntu Nginx上安装fcgiwrap
    fcgiwrap是一个简单的服务器,用于在FastCGI上运行CGI应用程序。我们可以用它来为nginxwebserver提供干净的CGI支持。它是一个轻量级的服务器,具有零配置选项,可以使用同一个池来运行不同的站点。本文介绍了如何在Ubuntu20.04上安装fcgiwrap。CGI的意思是CommonGatewayInterface,......
  • PLSQL 12安装及汉化
    目录一、下载1.下载PLSQL(本次安装的PLSQL版本为12.0.7,建议安装64位)2.下载汉化包3.注册码二、安装1.双击运行plsqldev1207x64.msi开始安装2.接受协议并选择版本3.如果不想安装到默认路径,可点击“Change”按钮,自定义安装路径4.选择安装方式5.点击“Install”开始......
  • 安装 R package KEGG.db
    目前我的R版本是4.0以上的,已经找不到KEGG.db的package了,只能手动来~~ 首先,在bioconductor的主页搜索KEGG.db,然后找到在KEGG.db的页面,找到下载链接 https://bioconductor.org/packages/3.6/data/annotation/src/contrib/KEGG.db_3.2.3.tar.gz。在我的ubuntu终端上,wget ......