How to setup java development environment in the ubuntu(11.10)?
here are some steps:
- 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/ - Extract and install it.
点击(此处)折叠或打开- sudo tar zxvf ~/Downloads/jdk-7u3-linux-i586.tar.gz -C /usr/lib/jvm
- #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: - 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 - 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. - 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
- Modify your Environment
点击(此处)折叠或打开- vim ~/.bashrc
- export JAVA_HOME=/usr/lib/jvm/jdk_1.7.0_03
- export JRE_HOME=${JAVA_HOME}/jre
- export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
- export PATH=${JAVA_HOME}/bin:$PATH
- #and then save it.
- Config the default java in your system:
- sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk_1.7.0_03/bin/java 300
- sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk_1.7.0_03/bin/javac 300
- sudo update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/jdk_1.7.0_03/bin/jar 300
- df
- sudo update-alternatives --config java
- #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."
- Check your java now:
- ray@ray-laptop:~$ java -version
- java version "1.7.0_03"
- Java(TM) SE Runtime Environment (build 1.7.0_03-b04)
- Java HotSpot(TM) Client VM (build 22.1-b02, mixed mode)
Reference:
阅读(1273) | 评论(0) | 转发(0) |