Java安装
安装SUN的JDK:
官网:http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
在/usr下建立一个java目录,以备将java程序安装在此目录下,输入如下命令:
[[email protected] ~]# mkdir /usr/java/
把下载好的文件上传到/usr/java/目录下:
[[email protected] ~]# cd /usr/java/ [[email protected] java]# ll -rw-r--r-- 1 root root 185540433 7月 8 07:16 jdk-8u131-linux-x64.tar.gz
解压文件并且更换目录名:
[[email protected] java]# tar zxvf jdk-8u131-linux-x64.tar.gz [[email protected] java]#mv jdk1.8.0_131/ /usr/java/jdk
最后进行环境变量的设置。输入如下命令,进入配置文件:
[[email protected] ~]# vim /etc/profile export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL export JAVA_HOME=/usr/java/jdk export PATH=$JAVA_HOME/bin:$PATH export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
执行配置文件,令其立刻生效,输入如下命令:
[[email protected] ~]# source /etc/profile
查看当前版本:
[[email protected] ~]# java -version java version "1.8.0_131" Java(TM) SE Runtime Environment (build 1.8.0_131-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
创建java程序进行测试:
[[email protected] ~]# vim HelloWorld.java public class HelloWorld{ public static void main(String []args){ System.out.print("hello world\n"); } }
执行验证:
[[email protected] ~]# javac HelloWorld.java [[email protected] ~]# java HelloWorld hello world
时间: 2024-10-07 11:24:56