<commit_before>---
layout: documentation
title: Installing Bazel
---

# Installing Bazel

Supported platforms:

*   [Ubuntu Linux (Wily 15.10 and Trusty 14.04 LTS)](#ubuntu)
*   [Mac OS X](#mac-os-x)
*   [Windows (highly experimental)](#windows)

For other platforms, you can try to [compile from source](#compiling-from-source).

Required Java version:

*   Java JDK 8 or later ([JDK 7](#jdk7) is still supported
    but deprecated).

Extras:

*   [Bash completion](#bash)
*   [zsh completion](#zsh)

For more information on using Bazel, see [Getting
started](getting-started.html).


## <a name="ubuntu"></a>Ubuntu

Install Bazel on Ubuntu using one of the following methods:

  * [Using our custom APT repository](#install-on-ubuntu)
  * [Using binary installer](#install-with-installer-ubuntu)
  * [Compiling Bazel from source](#compiling-from-source)

### <a name="install-on-ubuntu"></a> Using Bazel custom APT repository (recommended)

#### 1. Install JDK 8

If you are running **Ubuntu Wily (15.10)**, you can skip this step.
But for **Ubuntu Trusty (14.04 LTS)** users, since OpenJDK 8 is not available on Trusty, please install Oracle JDK 8:

```
$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java8-installer
```

Note: You might need to `sudo apt-get install software-properties-common` if you don't have the `add-apt-repository` command. See [here](http://manpages.ubuntu.com/manpages/wily/man1/add-apt-repository.1.html).

#### 2. Add Bazel distribution URI as a package source (one time setup)

```
$ echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
$ curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -
```

If you want to use the JDK 7, please replace `jdk1.8` with `jdk1.7` and if you want to install the testing version of Bazel, replace `stable` with `testing`.

#### 3. Update and install Bazel

`$ sudo apt-get update && sudo apt-get install bazel`

Once installed, you can upgrade to newer version of Bazel with:

`$ sudo apt-get upgrade bazel`

### <a name="install-with-installer-ubuntu"></a>Install with Installer

We provide binary installers on our
<a href="https://github.com/bazelbuild/bazel/releases">GitHub releases page</a>

The installer only contains Bazel binary, some additional libraries are required to be installed on the machine to work.

<commit_msg>bazel - improve the order for update and install.<commit_after>---
layout: documentation
title: Installing Bazel
---

# Installing Bazel

Supported platforms:

*   [Ubuntu Linux (Wily 15.10 and Trusty 14.04 LTS)](#ubuntu)
*   [Mac OS X](#mac-os-x)
*   [Windows (highly experimental)](#windows)

For other platforms, you can try to [compile from source](#compiling-from-source).

Required Java version:

*   Java JDK 8 or later ([JDK 7](#jdk7) is still supported
    but deprecated).

Extras:

*   [Bash completion](#bash)
*   [zsh completion](#zsh)

For more information on using Bazel, see [Getting
started](getting-started.html).


## <a name="ubuntu"></a>Ubuntu

Install Bazel on Ubuntu using one of the following methods:

  * [Using our custom APT repository](#install-on-ubuntu)
  * [Using binary installer](#install-with-installer-ubuntu)
  * [Compiling Bazel from source](#compiling-from-source)

### <a name="install-on-ubuntu"></a> Using Bazel custom APT repository (recommended)

#### 1. Install JDK 8

If you are running **Ubuntu Wily (15.10)**, you can skip this step.
But for **Ubuntu Trusty (14.04 LTS)** users, since OpenJDK 8 is not available on Trusty, please install Oracle JDK 8:

```
$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java8-installer
```

Note: You might need to `sudo apt-get install software-properties-common` if you don't have the `add-apt-repository` command. See [here](http://manpages.ubuntu.com/manpages/wily/man1/add-apt-repository.1.html).

#### 2. Add Bazel distribution URI as a package source (one time setup)

```
$ echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
$ curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -
```

If you want to use the JDK 7, please replace `jdk1.8` with `jdk1.7` and if you want to install the testing version of Bazel, replace `stable` with `testing`.

#### 3. Install and update Bazel

`$ sudo apt-get update && sudo apt-get install bazel`

Once installed, you can upgrade to newer version of Bazel with:

`$ sudo apt-get upgrade bazel`

### <a name="install-with-installer-ubuntu"></a>Install with Installer

We provide binary installers on our
<a href="https://github.com/bazelbuild/bazel/releases">GitHub releases page</a>

The installer only contains Bazel binary, some additional libraries are required to be installed on the machine to work.


{'fraction_non_alphanumeric': 0.1267835303709743, 'fraction_numerical': 0.015491235222176927, 'mean_word_length': 4.304864864864865, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6067063', 'n_tokens_mistral': 1763, 'n_tokens_neox': 1548, 'n_words': 553}