unbuntu java环境安装与设置(chenxl)

来源:互联网 发布:运维和网络哪个好 编辑:程序博客网 时间:2024/05/01 03:39
安装jre 
1)sudo apt-get install sun-java5-jre
安装jdk
2)
sudo apt-get install sun-java5-jdk
我的源如下:

deb http://cn.archive.ubuntu.com/ubuntu/ dapper main restricted
deb-src http://cn.archive.ubuntu.com/ubuntu/ dapper main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://cn.archive.ubuntu.com/ubuntu/ dapper-updates main restricted
deb-src http://cn.archive.ubuntu.com/ubuntu/ dapper-updates main restricted

## Uncomment the following two lines to add software from the 'universe'
## repository.
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## universe WILL NOT receive any review or updates from the Ubuntu security
## team.
# deb http://cn.archive.ubuntu.com/ubuntu/ dapper universe
# deb-src http://cn.archive.ubuntu.com/ubuntu/ dapper universe

## Uncomment the following two lines to add software from the 'backports'
## repository.
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
# deb http://cn.archive.ubuntu.com/ubuntu/ dapper-backports main restricted universe multiverse
# deb-src http://cn.archive.ubuntu.com/ubuntu/ dapper-backports main restricted universe multiverse

deb http://security.ubuntu.com/ubuntu dapper-security main restricted
deb-src http://security.ubuntu.com/ubuntu dapper-security main restricted
# deb http://security.ubuntu.com/ubuntu dapper-security universe
# deb-src http://security.ubuntu.com/ubuntu dapper-security universe
# deb http://tonelli.sns.it/pub/mplayer/etch ./
# The Opera browser (packages)
#deb http://deb.opera.com/opera etch non-free
#deb ftp://ftp.nerim.net/debian-marillat/ stable main
# (00:24:00) AnThOnYhO: 这三个是w32codecs的源
#deb ftp://ftp.nerim.net/debian-marillat/ sarge main
#deb ftp://ftp.nerim.net/debian-marillat/ sid main
#deb ftp://ftp.nerim.net/debian-marillat/ etch main
#deb http://debian.cn99.com/ubuntu-cn dapper main

3)环境变量设置:
   sudo update-alternatives --config java
   选择 3 sun

4)测试:
    输入  java -version
  会出现java版本
  编写个helloworld程序
   public class HelloWorld{
    public static void main(String[] args){
        System.out.println("hello world!");
    }
}

编译:javac HelloWorld.java
执行:java HelloWorld
输出  : hello world !
恭喜你 !!!!安装成功
 
原创粉丝点击