---
metadata:
  - name: generator
    content: Diplodoc Platform v5.52.0
alternate:
  - https://catboost.ai/docs/en/installation/java-installation-build-from-source-maven.md
  - href: en/installation/java-installation-build-from-source-maven.md
    type: text/markdown
    title: Markdown version
  - href: ../llms.txt
    type: text/markdown
    title: llms.txt
---
> **Documentation Index:** Fetch the complete configuration index at https://catboost.ai/docs/en/llms.txt

# Build from source using Maven

## Dependencies and requirements

{% note warning %}

<!-- source: en/_includes/work_src/reusage-installation/ya-make-to-cmake-switch.md -->
CatBoost uses [CMake](https://cmake.org/)-based build process since [this commit](https://github.com/catboost/catboost/commit/c5c642ca0b8e093336d0229ac4b14c78db3915bb). Previously `Ya Make` (Yandex's build system) had been used.
<!-- endsource: en/_includes/work_src/reusage-installation/ya-make-to-cmake-switch.md -->

Select the appropriate build environment setup below accordingly.

{% endnote %}

* Linux, macOS or Windows.

* Set up build environment depending on build type:
  - [For CMake](https://catboost.ai/docs/en/installation/build-environment-setup-for-cmake.md)
  - [For Ya Make](https://catboost.ai/docs/en/installation/build-environment-setup-for-ya-make.md)

* Python. 3.6+
* Maven 3.3.9+
* JDK 8+

  Set `JAVA_HOME` environment variable to point to the path of JDK installation

## CUDA support

[CUDA](https://developer.nvidia.com/cuda) support is available for Linux and Windows target platforms.
It is disabled by default and can be enabled by adding `--have-cuda` flag to `buildNative.extraArgs` definition. See below for details.

<!-- source: en/_includes/work_src/reusage-installation/build-cuda-architectures.md -->
CUDA architectures to generate device code for are specified using [`CMAKE_CUDA_ARCHITECTURES` variable](https://cmake.org/cmake/help/v3.24/variable/CMAKE_CUDA_ARCHITECTURES.html), although the default value is non-standard, [specified in `cuda.cmake`](https://github.com/catboost/catboost/blob/5fb7b9def07f4ea2df6dcc31b5cd1e81a8b00217/cmake/cuda.cmake#L7). The default value is intended to provide broad GPU compatibility and supported only when building with CUDA 11.8.
The most convenient way to override the default value is to use [`CUDAARCHS` environment variable](https://cmake.org/cmake/help/v3.24/envvar/CUDAARCHS.html).
<!-- endsource: en/_includes/work_src/reusage-installation/build-cuda-architectures.md -->

## Building steps

1. Clone the repository:

    ```
    git clone https://github.com/catboost/catboost.git
    ```

2. Go to the `catboost/catboost/jvm-packages/catboost4j-prediction` directory from the local copy of the CatBoost repository.
3. Use [the usual maven build phases](https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html) in this directory.

   Additional flags for building native dynamic library part can specified using `buildNative.extraArgs` definition.
   Supported flags are:
   * `--build-system=<build_system>`. Supported values are `CMAKE` (default), `YA`.
   * `--build-type=<build_type>`. Supported values are `Release` (default), `Debug`.
   * `--have-cuda`. Add to enable CUDA support.
   Example running tests with this definition:
   ```
   mvn test -DbuildNative.extraArgs="--build-type=Debug"
   ```
