Ubuntu重装后Java环境的设置

java下载地址在这里,检测你是否有
java 路径的方法是在终端中运行 which java,我得到了/usr/bin/java

本文转载自:

1.下载jdk1.7.0_67并且解压,放知道/usr/local/lib/jvm目录下

tar zxvf jdk1.7.0_67.tar.gz
sudo mv jdk1.7.0_67 /usr/local/lib/jvm

如果Ubuntu下安装了sun
java用下面的命令
export MATLAB_JAVA=/usr/lib/jvm/jdk1.6.0_10/jre/
如没没有,使用matlab自带的
export MATLAB_JAVA=/home/matlab2008b/sys/java/jre/glnx86/jre
参考自
ust to follow up on this, in case anyone out there is interested, I am
now using Compiz version 0.6.3~git20080115.0ea58487-1 on Debian Lenny
with kernel 2.6.24-1-amd64, and I am running Matlab 2008a. I have found
that the latest snapshot of the JRE is working relatively well with
Matlab, which you can find at . I
instruct Matlab to use this JRE by adding this line

一、安装包下载:

2.编辑~/.bashrc文件,添加如下内容。

JAVA_HOME后的内容为你自定义的JDK存放目录

export JAVA_HOME=/usr/local/lib/jvm/jdk1.7.0_67
export JRE_HOME=${JAVA_HOME}/jre
exportCLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH

export MATLAB_JAVA=/usr/lib/jvm/jdk1.6.0_10/jre/

  1. jdk-8u152-linux-x64.tar.gz下载:

3.设置JDK默认版本

sudo update-alternatives –install “/usr/bin/java/” “java”
“/usr/local/lib/jvm/jdk1.7.0_67/bin/java” 300

sudo update-alternatives –install “/usr/bin/javac” “javac”
“/usr/local/lib/jvm/jdk1.7.0_67/bin/javac” 300

sudo update-alternatives –install “/usr/bin/jar” “jar”
“/usr/local/lib/jvm/jdk1.7.0_67/bin/jar” 300

sudo update-alternatives –install “/usr/bin/javah” “javah”
“/usr/local/lib/jvm/jdk1.7.0_67/bin/javah” 300

sudo update-alternatives –install “/usr/bin/javap” “javap”
“/usr/local/lib/jvm/jdk1.7.0_67/bin/javap” 300

sudo update-alternatives –install “/usr/bin/javaws” “javaws”
“/usr/local/lib/jvm/jdk1.7.0_67/bin/javaws” 300

sudo update-alternatives –set java
/usr/local/lib/jvm/jdk1.7.0_67/bin/java
sudo update-alternatives –set javac
/usr/local/lib/jvm/jdk1.7.0_67/bin/javac
sudo update-alternatives –set jar
/usr/local/lib/jvm/jdk1.7.0_67/bin/jar
sudo update-alternatives –set javah
/usr/local/lib/jvm/jdk1.7.0_67/bin/javah
sudo update-alternatives –set javap
/usr/local/lib/jvm/jdk1.7.0_67/bin/javap
sudo update-alternatives –set javaws
/usr/local/lib/jvm/jdk1.7.0_67/bin/javaws

to the Matlab startup script which for me is located at
/usr/local/matlab76/bin/matlab (your Matlab root may differ, and the
location of your JRE may differ). One key requirement is that you create
the symbolic link from motif21 to motif12 in the amd64 directory which
for me is located in /usr/lib/jvm/jdk1.6.0_10/jre/lib/amd64 (again your
location may differ). I have found that the old workaround “export
AWT_TOOLKIT=MToolkit” cannot be set for any of this to work. Also know
that the motif12 link is a
total kluge that I don’t understand, so proceed at your own risk. Good
luck!

    wget

4.检查

java -version
mik3y@mac:~$ java -version
java version “1.7.0_67”
Java(TM) SE Runtime Environment (build 1.7.0_67-b01)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

图片 1

  1. maven-3/3.3.9下载:

5.使火狐浏览器支持java插件

sudo find / -name libnpjp2.so
/usr/local/lib/jvm/jdk1.7.0_67/jre/lib/amd64/libnpjp2.so
cd ~
mkdir -pv .mizilla/plugins
cd .mizilla/plugins
ln -sf /usr/local/lib/jvm/jdk1.7.0_67/jre/lib/amd64/libnpjp2.so
~/.mizilla/plugins

Firefox:
URL地址栏中输入:about:plugins会浏览到JAVA TM 相关的内容,接下来测试
http://www.java.com/en/download/installed.jsp

    wget

  1. jenkins-2.88-1.1下载:

    wget

二、安装

  1. jdk安装:

tar -zxvf jdk-8u152-linux-x64.tar.gz

然后拷贝至自己安装软件的地方(我的是:/home/work/zach/soft/jdk1.8.0_152)

  1. maven安装:

tar -zxvf apache-maven-3.3.9-bin.tar.gz

然后拷贝至自己安装软件的地方(我的是:/home/work/zach/soft/maven)

  1. jenkins安装:

rpm -ivh jenkins-2.88-1.1.noarch.rpm

jenkins默认安装至 /var/lib/jenkins

三、配置:

  1. jdk与maven:

vim /etc/profile

unset i

unset -f pathmunge

export JAVA_HOME=/home/work/zach/soft/jdk1.8.0_152

export MAVEN_HOME=/home/work/zach/soft/maven

export JRE_HOME=${JAVA_HOME}/jre

export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib

export PATH=$JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH

保存后执行:source /etc/profile

  1. 启动jenkins前需修改 /etc/rc.d/init.d/jenkins:

vim /etc/rc.d/init.d/jenkins

candidates=”

/etc/alternatives/java

/usr/lib/jvm/java-1.6.0/bin/java

/usr/lib/jvm/jre-1.6.0/bin/java

/usr/lib/jvm/java-1.7.0/bin/java

/usr/lib/jvm/jre-1.7.0/bin/java

/usr/lib/jvm/java-1.8.0/bin/java

/usr/lib/jvm/jre-1.8.0/bin/java

/usr/bin/java

/home/work/zach/soft/jdk1.8.0_152/bin/java

加粗为修改的地方

四、权限问题

  1. Open up the this script (using VIM or other editor):

vim /etc/sysconfig/jenkins

  1. Find this $JENKINS_USER and change to “root”:

$JENKINS_USER=”root”

  1. Then change the ownership of Jenkins home, webroot and logs:

chown -R root:root /var/lib/jenkins

chown -R root:root /var/cache/jenkins

chown -R root:root /var/log/jenkins

4) Restart Jenkins and check the user has been changed:

service jenkins restart