Chinaunix首页 | 论坛 | 博客
  • 博客访问: 404118
  • 博文数量: 112
  • 博客积分: 4535
  • 博客等级: 上校
  • 技术积分: 1120
  • 用 户 组: 普通用户
  • 注册时间: 2007-06-12 10:57
文章分类

全部博文(112)

文章存档

2014年(1)

2013年(1)

2012年(18)

2011年(10)

2010年(16)

2009年(48)

2008年(9)

2007年(9)

我的朋友

分类: LINUX

2012-04-21 15:48:35

How to setup java development environment in the ubuntu(11.10)?

here are some steps:
  1. Choose a version of java and download it from the Oracle

    I choose the jdk_1.7.0_03 here, and download it into ~/Downloads/
  2. Extract and install it.
    点击(此处)折叠或打开
    1. sudo tar zxvf ~/Downloads/jdk-7u3-linux-i586.tar.gz -C /usr/lib/jvm
    2. #Note please:
      #you can change the name of jdk,
      #BUT CAN'T create a symbolic link to it otherwise the you will get error message like below:
    3. ray@ray-laptop:~$ ls -l /usr/lib/jvm/
      total 4
      lrwxrwxrwx 1 ray ray   12 2012-04-21 15:57 java_7_sun -> jdk1.7.0_03/
      drwxr-xr-x 8 ray ray 4096 2012-01-21 02:37 jdk1.7.0_03
    4. ray@ray-laptop:~$ sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/java-7-sun/bin/java 300
      update-alternatives: error: alternative path /usr/lib/jvm/java-7-sun/bin/java doesn't exist.
    5. ray@ray-laptop:~$ ls -l /usr/lib/jvm/java_7_sun/bin/java
      -rwxr-xr-x 1 ray ray 5654 2012-01-21 02:27 /usr/lib/jvm/java_7_sun/bin/java

  3. Modify your Environment
    点击(此处)折叠或打开
    1. vim ~/.bashrc
    2. export JAVA_HOME=/usr/lib/jvm/jdk_1.7.0_03
    3. export JRE_HOME=${JAVA_HOME}/jre
    4. export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
    5. export PATH=${JAVA_HOME}/bin:$PATH
    6. #and then save it.
  4. Config the default java in your system:

    点击(此处)折叠或打开

    1. sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk_1.7.0_03/bin/java 300
    2. sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk_1.7.0_03/bin/javac 300
    3. sudo update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/jdk_1.7.0_03/bin/jar 300
    4. df
    5. sudo update-alternatives --config java 
    6. #and then follow the promotion and take your choice.
      #Here is my output of this command:
      "There is only one alternative in link group java: /usr/lib/jvm/jdk_1.7.0_03/bin/java
      Nothing to configure."

  5. Check your java now: 
  6. 点击(此处)折叠或打开

    1. ray@ray-laptop:~$ java -version
    2. java version "1.7.0_03"
    3. Java(TM) SE Runtime Environment (build 1.7.0_03-b04)
    4. Java HotSpot(TM) Client VM (build 22.1-b02, mixed mode)


Reference:


阅读(1265) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~