参考资料:
http://developer.android.com/sdk/installing.html#which

一、Windows下环境搭建
参考:http://anzhiba.com/how-to-test-drive-google-android-on-your-pc/

1. Prepare your development computer

Read the System Requirements document and make sure that your development computer meets the hardware and software requirements for the Android SDK. Install any additional software needed before downloading the Android SDK. In particular, you may need to install the JDK (version 5 or 6 required) and Eclipse (version 3.4 or 3.5, needed only if you want develop using the ADT Plugin).  If you need to install Eclipse, you can download it from this location:

http://www.eclipse.org/downloads/

A Java or RCP version of Eclipse is recommended. For Eclipse 3.5, the "Eclipse Classic" version is recommended.

说明:需要安装Java JDK环境,用集成开发环境IDE的话最好安装Eclipse Classic版本3.5以上
Java JDK下载地址:http://www.oracle.com/technetwork/java/javase/downloads/index.html
下载Windows JDK版本的,当JDK下载完后如JavaSetup6u22.exe,双击运行

2. Download and install the SDK starter package

Select a starter package from the table at the top of this page and download it to your development computer. To install the SDK, simply unpack the starter package to a safe location and then add the location to your PATH.

Download the Android SDK

Platform Package Size MD5 Checksum
Windows android-sdk_r07-windows.zip 23669664 bytes 69c40c2d2e408b623156934f9ae574f0
Mac OS X (intel) android-sdk_r07-mac_x86.zip 19229546 bytes 0f330ed3ebb36786faf6dc72b8acf819
Linux (i386) android-sdk_r07-linux_x86.tgz 17114517 bytes e10c75da3d1aa147ddd4a5c58bfc3646

3. Install the ADT Plugin for Eclipse

If you are developing in Eclipse, set up a remote update site at https://dl-ssl.google.com/android/eclipse/. Install the Android Development Tools (ADT) Plugin, restart Eclipse, and set the "Android" preferences in Eclipse to point to the SDK install location. For detailed instructions, see ADT Plugin for Eclipse.

4. Add Android platforms and other components to your SDK

Use the Android SDK and AVD Manager, included in the SDK starter package, to add one or more Android platforms (for example, Android 1.6 or Android 2.2) and other components to your SDK. If you aren't sure what to add, see Which components do I need?

To launch the Android SDK and AVD Manager on Windows, execute SDK Setup.exe, at the root of the SDK directory. On Mac OS X or Linux, execute the android tool in the <sdk>/tools/ folder. For detailed instructions, see Adding SDK Components.

windows下安装过程简单按照官方说明就可以,不过是English的


二、Linux下Android SDK安装
1、JAVA SDK的安装
http://www.oracle.com/technetwork/java/javase/downloads/index.html下载Linux JDK版本的jdk-6u22-linux-i586.bin,然后安装:

Installation Instructions

This procedure installs the Java Development Kit (JDK) for 32-bit Linux, using a self-extracting binary file. The JDK download includes the Java SE Runtime Environment (JRE) – you do not have to download the JRE separately.

For RPM-based Linux distributions, like Red Hat or SuSE, refer to the RPM installation instructions.

The name of the downloaded file has the following format:

    jdk-6u

<version>-linux-i586.bin

<version>

    jdk-6u18-linux-i586.bin

To install, download this file and use the following instructions.

1. Download and check the download file size.

You can download to any directory that you can write to.

This bundle can be installed by anyone (not only root users), in any location that the user can write to. However, only the root user can displace the system version of the Java platform supplied by Linux.

2. Make sure that execute permissions are set

Run this command:
% chmod a+x jdk-6u <version>-linux-i586.bin

3. Change directory to the location where you would like the files to be installed.

The next step installs the JDK into the current directory.

4. Run the self-extracting binary.

Execute the downloaded file, prepended by the path to it. For example, if the file is in the current directory, prepend it with " ./" (necessary if " ." is not in the PATH environment variable):

% ./jdk-6u <version>-linux-i586.bin

The binary code license is displayed, and you are prompted to agree to its terms.

The JDK files are installed in a directory called jdk1.6.0_<version> in the current directory. Follow this link to see its directory structure. The JDK documentation is a separate download.

5. Delete the bin file if you want to save disk space.

6. If you want to use Java within the browser, setup the plugin using the instructions in Manual Plugin Installation for Linux.

Note about Root Access: Installing the software automatically creates a directory called jdk1.6.0_ <version> . Note that if you choose to install the JDK into a system-wide location such as /usr/local, you must first become root to gain the necessary permissions. If you do not have root access, simply install the Java SE Runtime Environment into your home directory, or a subdirectory that you have permission to write to.

Note about Overwriting Files: If you install the software in a directory that contains a subdirectory named jdk1.6.0_ <version> , the new software overwrites files of the same name in that jdk1.6.0_ <version> directory. Please be careful to rename the old directory if it contains files you would like to keep.

Note about System Preferences: By default, the installation script configures the system such that the backing store for system preferences is created inside the JDK's installation directory. If the JDK is installed on a network-mounted drive, it and the system preferences can be exported for sharing with Java runtime environments on other machines.

# chmod +x jdk-6u13-linux-i586.bin

# ./jdk-6u13-linux-i586.bin

程序运行后会当前目录下生成一个名为 jdk1.6.0_13 的目录

把该目录拷贝到/usr/local/jdk1.6.0_13 ,并在系统初始化脚本中增加以下两个环境变量

export CLASSPATH=/usr/local/jdk1.6.0_13/lib

export JAVA_HOME=/usr/local/jdk1.6.0_13

用java -version命令进行测试

最后设置java的环境变量, 修改 /etc/profile 在 最后 增加

PATH=/usr/lib/j2sdk1.6-sun/bin:$PATH

JAVA_HOME=/usr/lib/j2sdk1.6-sun/

CLASSPATH=.:/usr/lib/j2sdk1.6-sun/jre/lib

export PATH

export JAVA_HOME

export CLASSPATH

OK 安装完成

如何在ubuntu中安装jdk-6u22

一,下载jdk安装文件:jdk-6u22-linux-i586.bin

http://cds-esd.sun.com/ESD6/JSCDL/jdk/6u22-b04/jdk-6u22-linux-i586.bin?AuthParam=1287976412_0b5159c90af0ead95afdf27cfca9c72d&TicketId=nod0A1oVTnJ%2FkOMul0WfUZadcQ%3D%3D&GroupName=CDS&FilePath=/ESD6/JSCDL/jdk/6u22-b04/jdk-6u22-linux-i586.bin&File=jdk-6u22-linux-i586.bin

二,解压jdk文件

更改bin文件执行权限

chmod +x jdk-6u22-linux-i586.bin

再解压

./jdk-6u22-linux-i586.bin

得到这个新的被解压的目录

jdk1.6.0_22

三,移动目录jdk1.6.0_22 到 /usr/lib/jvm/java/
注意:如果/usr/lib目录下没有jvm目录,要自己新建jvm目录,用命令:sudo mkdir jvm; sudo mkdir /jvm/java

四,修改环境变量

sudo cp /etc/environment environment-old [说明:这是备份一下配置文件]
sudo gedit /etc/environment

修改配置文件如下:
-----------------------------------
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"TH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/u
sr/bin:/sbin:/bin:/usr/games:/usr/lib/jvm/java/jdk1.6.0_22/bin"

CLASSPATH=.:/usr/lib/jvm/java/jdk1.6.0_22/lib

JAVA_HOME=/usr/lib/jvm/java/jdk1.6.0_22
-----------------------------------
主要是修改了3个地方:
1,在PATH上,添加了:/usr/lib/jvm/java/jdk1.6.0_22/bin
2,添加了 CLASSPATH=.:/usr/lib/jvm/java/jdk1.6.0_22/lib
3,添加了 JAVA_HOME=/usr/lib/jvm/java/jdk1.6.0_22

五,由于ubuntu中有默认jdk还需要执行如下工作
执行代码:

sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/java/jdk1.6.0_22/bin/java 300

sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/java/jdk1.6.0_22/bin/javac 300

六,通过这一步将我们安装的JDK加入java选单然后执行代码:
sudo update-alternatives --config java
[说明:这一步不必要,没有做任何改变]

七,验证是否安装成功
在shell中执行:
java -version
or
javac -version

然后首先我们安装Java JDK,到官网下载
 
为了方便安装 我们下载jdk-6u22-linux-i586.bin
然后在usr目录下新建java文件夹
先进入usr目录,输入cd /usr,然后输入mkdir java
然后将下载好的文件复制到java文件夹中
cp /你下载文件的路径/jdk-6u22-linux-i586.bin /usr/java/jdk-6u22-linux-i586.bin
然后输入 ./jdk-6u22-linux-i586.bin执行安装,安装的目录为/usr/java/jdk1.6.0_22
查看该目录下内容可发现与windows下安装目录完全一样
此时即完成了安装,接下来我们设置环境变量
输入 cd /etc 进入 /etc目录
输入vi profile 编辑profile文件
在最后加入以下内容
export JAVA_HOME=/usr/java/jdk1.6.0_22
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOMR/bin
有关vi编辑器的命令请大家自己网上搜寻下,这里就不一点一点说了
然后重新启动系统
打开终端输入
echo $JAVA_HOME
echo $PATH
javac -version
javac -help
就可看到如下图
从窗口中我们可以看出4个命令都正确的输出了我们想要的结果,这表明Java JDk的安装和配置就成功了。

1.安装JDK

拷贝jdk-6u22-linux-i586.bin到某个目录,例如:/opt/itdev/Java/,然后修改权限为777:

$sudo chmod 777 jdk-6u22-linux-i586.bin

之后开始安装,执行:

$sudo ./jdk-6u22-linux-i586.bin

一路安装即可。所以jdk的安装目录为/opt/itdev/Java/jdk1.6.0_22。

2. JAVA环境配置

JAVA环境配置涉及道两个文件:

/etc/profile –>是系统启动加载索引

/etc/environment->是环境变量

设置PATH,JAVA_HOME,CLASSPATH环境变量:

修改第一个文件/etc/environment(记得修改前备份: sudo cp /etc/environment  /etc/environment_backup)

$sudo gedit /etc/environment

打开之后内容如下:

PATH=”/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games”

在后面添加如下配置:

export JAVA_HOME = /opt/itdev/Java/jdk1.6.0_22
export JRE_HOME = /opt/itdev/Java/jdk1.6.0_22/jre
export CLASSPATH = $CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib

保存关闭即可,注意把以上路经修改为你机子上Java的安装目录。

修改第二个文件/etc/profile,同样记得备份。

$sudo gedit /etc/profile

打开之在profile文件的末尾,umask 022之前加上以下设置的语句:

export JAVA_HOME=/opt/itdev/Java/jdk1.6.0_22
export JRE_HOME=/opt/itdev/Java/jdk1.6.0_22/jre
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOME/bin
umask 022

保存关闭即可。然后重启电脑。重启之后查看环境变量配置状况:
leyond@ubuntu:~$ echo $JAVA_HOME
/opt/itdev/Java/jdk1.6.0_22
leyond@ubuntu:~$ echo $CLASSPATH
:/opt/itdev/Java/jdk1.6.0_22/lib:/opt/itdev/Java/jdk1.6.0_22/jre/lib
leyond@ubuntu:~$ echo $PATH
/opt/itdev/Java/jdk1.6.0_22/bin:/opt/itdev/Java/jdk1.6.0_22/jre/bin:/usr/local/sbin:/usr/local/bin:
/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/leyond/bin

查看Java版本:

leyond@ubuntu:~$ java -version
java version “1.6.0_22″

JAVA JDK安装和配置到此结束。

一、下载安装JDK1.6
1、下载jdk1.6的官方地址:
http://www.oracle.com/technetwork/java/javase/downloads/index.html

2、jdk1.6提供以下两种自解压文件:
   1)jdk-6u22-linux-i586.bin
   2)jdk-6u22-linux-i586-rpm.bin
3、我下载的是jdk-6u22-linux-i586-rpm.bin
4、给所有用户添加可执行的权限
   #chmod +x jdk-6u22-linux-i586-rpm.bin
5、执行该文件,命令如下:
   #./jdk-6u22-linux-i586-rpm.bin
   执行后会解压出一些rpm软件包,其中有jdk-6u22-linux-i586.rpm这是主程式包,接下来就是安装这个主程序包。
6.、切换到root用户,进入jdk-6u22-linux-i586.rpm存放的目录,执行如下命令:
    rpm -ivh jdk-6u22-linux-i586.rpm
   安装软件会将JDK自动安装到 /usr/java/jdk-1.6.0_22-fcs目录下。

二、安装好jdk后配置环境变量。
1、修改用户环境变量
   假设使用java jdk的用户为 oracle,编辑该用户的.bashrc文件进行环境变量设置。
   在 .bashrc文件中加入:
   # vi /home/oracle/.bashrc
   export JAVA_HOME=/usr/java/jdk-1.6.0_22-fcs

  export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib

  export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOMR/bin

2、如果所有用户都想共享jdk的环境变量,可以通过如下方式设置。
   (但建议最好不要这样,万一有其他用户使用其他JKD就会受到影响。)
    在/etc/profile文件中加入:
  # vi /etc/profile   
  export JAVA_HOME=/usr/java/jdk-1.6.0_22-fcs
  export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
  export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOMR/bin

   注:修改文件后要想马上生效还要运行# source /etc/profile不然只能在下次重进此用户时生效。
  记得CLASSPATH路径中加入$CLASSPATH:不能在解释执行class文件时会报错。
   

三、卸载jdk1.6
1、卸载系统自带的jdk版本:
   查看自带的jdk:
   #rpm -qa|grep gcj
   看到如下信息:
   libgcj-4.1.2-44.el5
   java-1.4.2-gcj-compat-1.4.2.0-40jpp.115
   使用rpm -e --nodeps 命令删除上面查找的内容:
   #rpm -e –nodeps java-1.4.2-gcj-compat-1.4.2.0-40jpp.115

2、卸载rpm安装的jkd版本
   查看安装的jdk:
   #rpm -qa|grep jdk
   看到如下信息:
   jdk-1.6.0_22-fcs
   卸载:
   #rpm -e --nodeps jdk-1.6.0_22-fcs

1.下载的版本是jdk-6u22-linux-i586
2.目前登陆账号:ren 密码:renhaijian
3.由于账号ren对jdk安装无权限,我切换到了xjj下,具体步骤是
4.可先切换至root用户下,在终端中输入“su xjj”,在提示密码中输入“root”
5.在终端机模式下切换到 Ubuntu root 身份,sudo -s -H,输入密码:xjj
6.用cd命令进入jdk所在目录,执行复制命令 cp jdk-6u22-linux-i586.bin /usr 即将jdk复制到/usr目录下,然后进入/usr目录cd /usr
7.执行权限 chmod +x jdk-6u22-linux-i586.bin (注:这里授权用的是字符设定法,x代表可执行r-读,w-写,x-执行)
8.执行安装命令“./jdk-6u7-linux-i586.bin”,接下来会有安装提示信息,验证安装成功与否可“java -version"

===============================安装成功会显示如下信息
root@renhj:/usr# java -version
java version "1.6.0_0"
OpenJDK  Runtime Environment (build 1.6.0_0-b11)
OpenJDK Client VM (build 1.6.0_0-b11, mixed mode, sharing)
=========================================================
接下来设置jdk的环境变量

1.设置环境变量。#vi /etc/profile
2.这是界面从“命令模式”转入了“插入模式”,那就加上如下代码吧:
#set java environment
export JAVA_HOME=/usr/1.6.0_22
export CLASSPATH=.:$CLASSPATH:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
export JRE_HOME=$JAVA_HOME/jre

3.ESC---:wq(保存退出)
4要使JDK在所有的用户中使用,可以这样:
 vi /etc/profile.d/java.sh
 在新的java.sh中输入以下内容:
 #set java environment
 JAVA_HOME=/usr/java/jdk-1_5_0_02
 CLASSPATH=.:$JAVA_HOME/lib/tools.jar
 PATH=$JAVA_HOME/bin:$PATH
 export JAVA_HOME CLASSPATH PATH
 保存退出,然后给java.sh分配权限:chmod 755 /etc/profile.d/java.sh
5.在终端使用echo命令检查环境变量设置情况。
 #echo $JAVA_HOME
 #echo $CLASSPATH
 #echo $PATH
6.检查JDK是否成功安装。
        #java -version