Ubuntu下安装jdk1.8和eclipse

配置jdk参考https://www.linuxidc.com/Linux/2017-02/140908.htm

需要配置/etc/environment,配置完如下所示

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:$JAVA_HOME/bin"
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export JAVA_HOME=/opt/jvm/jdk1.8.0_191

再通过source /etc/environment生效

还要配置/etc/profile,配置完如下所示

# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

if [ "$PS1" ]; then
  if [ "$BASH" ] && [ "$BASH" != "/bin/sh" ]; then
    # The file bash.bashrc already sets the default PS1.
    # PS1='\h:\w\$ '
    if [ -f /etc/bash.bashrc ]; then
      . /etc/bash.bashrc
    fi
  else
    if [ "`id -u`" -eq 0 ]; then
      PS1='# '
    else
      PS1='$ '
    fi
  fi
fi

if [ -d /etc/profile.d ]; then
  for i in /etc/profile.d/*.sh; do
    if [ -r $i ]; then
      . $i
    fi
  done
  unset i
fi

#set Java environment

export JAVA_HOME=/opt/jvm/jdk1.8.0_191
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JAR_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

同样通过source /etc/profile生效

 

安装eclipse参考https://blog.csdn.net/qq_37549757/article/details/56012895

首先通过解压命令

sudo tar zxvf eclipse-inst-linux64.tar.gz -C /opt/ 

解压到/opt目录下,然后

cd /usr/share/applications

再然后

sudo vim eclipse.desktop 

输入如下内容

[Desktop Entry]
Encoding=UTF-8
Name=Eclipse
Comment=Eclipse
Exec=/opt/eclipse-installer/eclipse-inst
Icon=/opt/eclipse-installer/icon.xpm
Terminal=false
StartupNotify=true
Type=Application
Catagories=Application;Development;

再输入命令

sudo chmod u+x eclipse.desktop

然后将图标从/usr/share/applications粘贴到桌面打开安装即可。

posted @ 2018-12-01 16:52  css12345  阅读(179)  评论(0编辑  收藏  举报