<commit_before>---
layout: documentation
---

# Installing Bazel

## System Requirements

Supported platforms:

*   Ubuntu Linux
*   Mac OS X

Java:

*   Java JDK 7 or later

## Downloading Bazel

Clone the Bazel repo from GitHub:

```
$ cd $HOME
$ git clone https://github.com/google/bazel.git
```

## Building Bazel

### Building Bazel on Ubuntu

To build Bazel on Ubuntu:

#### 1. Install JDK 7:

**Ubuntu Utopic (14.10) and Trusty (14.04 LTS).** To install OpenJDK 7:

```
$ sudo apt-get install openjdk-7-jdk openjdk-7-source
```

#### 2. Set the `JAVA_HOME` environment variable.

First, check to see if it's already set:

```
$ echo $JAVA_HOME
```

If this prints the path to the JDK 7 root directory, proceed to the next
step. Otherwise, find the Java `bin` directory using `which javac` and use
`javac -version` to verify that you have the right JDK version. Then set
the `JAVA_HOME` environment variable to the `bin` directory parent.

For example, if the path is `/usr/lib/jvm/jdk1.7.0/bin/javac`, set the
`JAVA_HOME` variable to `/usr/lib/jvm/jdk1.7.0`:

```
$ export JAVA_HOME=/usr/lib/jvm/jdk1.7.0
```

You can also add this line to your `~/.bashrc` file.

#### 3. Install required packages:

```
$ sudo apt-get install pkg-config zip g++ zlib1g-dev
```

#### 4. Build Bazel:

```
$ cd bazel
$ ./compile.sh
```

### Building Bazel on OS X

Bazel on Mac OS X requires:

* The Xcode command line tools. Xcode can be downloaded from the
  [Apple Developer Site](https://developer.apple.com/xcode/downloads/).

* MacPorts or Homebrew for installing required packages.

* An installation of JDK 7.

* For `objc_*` and `ios_*` rule support, you must have Xcode 6.1 or later with
  iOS SDK 8.1 installed on your system.

To build Bazel on Mac OS X:

```<commit_msg>Update install.md for Linux's java settings<commit_after>---
layout: documentation
---

# Installing Bazel

## System Requirements

Supported platforms:

*   Ubuntu Linux
*   Mac OS X

Java:

*   Java JDK 7 or later

## Downloading Bazel

Clone the Bazel repo from GitHub:

```
$ cd $HOME
$ git clone https://github.com/google/bazel.git
```

## Building Bazel

### Building Bazel on Ubuntu

To build Bazel on Ubuntu:

#### 1. Install JDK 7:

**Ubuntu Utopic (14.10) and Trusty (14.04 LTS).** To install OpenJDK 7:

```
$ sudo apt-get install openjdk-7-jdk openjdk-7-source
```

#### 2. Install required packages:

```
$ sudo apt-get install pkg-config zip g++ zlib1g-dev
```

#### 3. Build Bazel:

```
$ cd bazel
$ ./compile.sh
```

If this fails to find a correct Java version, then try to
set the `JAVA_HOME` environment variable.

Find the Java `bin` directory using `readlink -f $(which javac)`
and use `javac -version` to verify that you have the right JDK version (1.7+).
Then set the `JAVA_HOME` environment variable to the `bin` directory
parent.

For example, if the path is `/usr/lib/jvm/jdk1.7.0/bin/javac`, set the
`JAVA_HOME` variable to `/usr/lib/jvm/jdk1.7.0`:

```
$ export JAVA_HOME=/usr/lib/jvm/jdk1.7.0
```

You can also add this line to your `~/.bashrc` file.


### Building Bazel on OS X

Bazel on Mac OS X requires:

* The Xcode command line tools. Xcode can be downloaded from the
  [Apple Developer Site](https://developer.apple.com/xcode/downloads/).

* MacPorts or Homebrew for installing required packages.

* An installation of JDK 7.

* For `objc_*` and `ios_*` rule support, you must have Xcode 6.1 or later with
  iOS SDK 8.1 installed on your system.

To build Bazel on Mac OS X:

```
{'fraction_non_alphanumeric': 0.12614678899082568, 'fraction_numerical': 0.018922018348623854, 'mean_word_length': 3.5370611183355005, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '864721', 'n_tokens_mistral': 1353, 'n_tokens_neox': 1223, 'n_words': 464}