1、拉取Ubuntu镜像
docker pull ubuntu:14.04
docker images
docker run -it 镜像ID号 bash
2、安装必备环境
sudo apt-get update && apt-get -y install vim && apt-get -y install vim
sudo apt-get install git gnupg flex bison gperf build-essential \
zip curl libc6-dev libncurses5-dev x11proto-core-dev \
libx11-dev libreadline6-dev libgl1-mesa-glx \
libgl1-mesa-dev g++-multilib mingw32 tofrodos \
python-markdown libxml2-utils xsltproc zlib1g-dev
注意:在Ubuntu14.04(64位)上面是无法安装libncurses5-dev:i386的,他会提示无法找到安装包,把:i386去掉即可安装成功。
- i386–>32位
- i486–>32位
- i586–>32位
- i686–>32位
- x86–>32位
- amd64–>64位
- x86_64(x64)–>64位
3、安装jdk
ubuntu安装jdk无非两种方式
i.通过命令行添加ppa源安装(反正我试过,没一个成功的,最后只能手动下载安装包)
#1-通过命令行添加ppa源安装
#方法一:
#将之前安装的删除:
sudo apt-get purge openjdk*
#添加ppa并更新
sudo add-apt-repository ppa:webupd8team/java && sudo apt-get update
#安装jdk
sudo apt-get install oracle-java8-installer
#配置环境变量
sudo apt-get install oracle-java8-set-default
#配置默认jdk及版本切换:
sudo update-java-alternatives -s java-8-oracle
#查看版本
java -version
#删除版本
sudo apt-get remove oracle-java8-installer
#参考地址:https://www.jianshu.com/p/1bd34ea947b4
#方法二:
sudo apt-get install sun-java6-jdk
#如果没有找到
sudo add-apt-repository “deb http://ppa.launchpad.net/sun-java-6/ppa/ubuntumaverick main ”
sudo add-apt-repository “deb-src http://ppa.launchpad.net/sun-java-6/ppa/ubuntumaverick main ”
sudo apt-get update
sudo apt-get install sun-java6-jdk
#参考地址:https://blog.csdn.net/yihui8/article/details/39854731
ii.通过官网下载安装包安装
- 1-先下载bin文件或者tar包
- jdk6 64位: http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase6-419409.html
- jdk5 64位: http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase5-419410.html
- jdk 7 64位:http://www.oracle.com/technetwork/cn/java/javase/downloads/java-se-jdk-7-download-432154-zhs.html
- jdk8 64位: https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
- 2-给权限,以便于后面的执行
- sudo chmod u+x /usr/lib/jvm/java/jdk-6-linux-i586.bin (注意,这和i586是32位的)
- 3-执行
- sudo /usr/lib/jvm/java/jdk-6-linux-i586.bin
- 4-修改环境变量
- sudo vi /etc/environment
- 添加
- PATH=”……:/usr/lib/jvm/java/jdk1.6.0/bin”
- CLASSPATH=.:/usr/lib/jvm/java/jdk1.6.0/lib
- JAVA_HOME=/usr/lib/jvm/java/jdk1.6.0
- 5-使环境变量生效
- source /etc/environment
- 6-Ubuntu中可能会有默认的jdk,openjdk,我们要把自己的添加进去
- sudo update-alternatives –install /usr/bin/java java /usr/lib/jvm/java/jdk1.6.0/bin/java 300
- sudo update-alternatives –install /usr/bin/javac javac /usr/lib/jvm/java/jdk1.6.0/bin/javac 300
- sudo update-alternatives –install /usr/bin/javah javah /usr/lib/jvm/java/jdk1.6.0/bin/javah 300
- 7-通过这一步选择默认的jdk
- sudo update-alternatives –config java
- sudo update-alternatives –config javac
- sudo update-alternatives –config javah
- 8-查看当前版本 java -version