ubuntu 11.10 jdk配置心得

在参阅了网上的一些资料,将实践小结一下,以备后用:


1、将home目录下的.bashrc文件尾部添加jdk配置如下:


export ANDROID_HOME=/home/stedy/gy/software/android-sdk-linux_86
export NDK_HOME=/home/stedy/gy/software/android-ndk-r7b
#export JAVA_HOME=/usr/lib/jvm/java-6-openjdk // 默认的java使用版本
export JAVA_HOME=/home/stedy/gy/software/jdk1.7.0_01

export CLASSPATH=.:$JAVA_HOME/jre/lib/dt.jar:$JAVA_HOME/jre/lib/tools.jar:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/jre/lib
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$NDK_HOME:$JAVA_HOME/bin


然后wq后再source .bashrc


2、配置默认java使用版本

     先了解一下update-alternatives: --install 的命令格式

      update-alternatives: --install needs <link> <name> <path> <priority>

     接下来:

                 sudo update-alternatives --install /usr/bin/java java /home/stedy/gy/software/jdk1.7.0_01/bin/java 300

                 sudo update-alternatives --install /usr/bin/javac javac /home/stedy/gy/software/jdk1.7.0_01/bin/javac 300

                 sudo update-alternatives --install /usr/bin/jar jar /home/stedy/gy/software/jdk1.7.0_01/bin/jar 300

    配置完成后执行:

               sudo update-alternatives --config java 来查看可用的java版本,接下来进行选择即可


                Selection    Path                                          Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-6-openjdk/jre/bin/java       1061      auto mode
  1            /home/stedy/gy/software/jdk1.7.0_01/bin/java   300       manual mode
  2            /usr/lib/jvm/java-6-openjdk/jre/bin/java       1061      manual mode

Press enter to keep the current choice[*], or type selection number: 1

作出以上选择后会弹出以下信息

update-alternatives: using /home/stedy/gy/software/jdk1.7.0_01/bin/java to provide /usr/bin/java (java) in manual mode.

Over!

















你可能感兴趣的:(java,jdk,android,jar,ubuntu,Path)