> For the complete documentation index, see [llms.txt](https://docs.afipsdk.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.afipsdk.com/integracion/java.md).

# Java

### Requisitos previos

Para poder seguir esta guía, primero necesitarás:

* [Obtener un access\_token de Afip SDK](https://app.afipsdk.com)

### 1. Instalación

Agregá la librería de Afip SDK en Java.

{% tabs %}
{% tab title="Maven" %}

```xml
<dependency>
    <groupId>com.afipsdk</groupId>
    <artifactId>afip-sdk-java</artifactId>
    <version>1.0.0</version>
</dependency>
```

{% endtab %}

{% tab title="Gradle" %}

```bash
implementation 'com.afipsdk:afip-sdk-java:1.0.0'
```

{% endtab %}
{% endtabs %}

### 2. Crear una instancia de la clase Afip

Para usar los Web Services de ARCA se necesita un certificado digital, pero con Afip SDK podés empezar en modo desarrollo usando el CUIT 20-40937847-2 sin necesidad de uno.

Si preferís [usar tu propio certificado](#usar-tu-propio-certificado-opcional), al final te mostramos cómo.

{% tabs %}
{% tab title="Main.java" %}

```java
import com.afipsdk.Afip;
import com.afipsdk.model.AfipOptions;

AfipOptions options = new AfipOptions();
options.setCuit("20409378472");
options.setProduction(false);
options.setAccessToken("TU_ACCESS_TOKEN"); // Obtenido de https://app.afipsdk.com

Afip afip = new Afip(options);
```

{% endtab %}
{% endtabs %}

### 3. Llamar al método del Web Service que necesites

Con la instancia creada ya podés realizar las llamadas a los Web Services que necesites.

{% content-ref url="/pages/mVTz5YrKc8PCEeJKHt0W" %}
[Web services](/siguientes-pasos/web-services.md)
{% endcontent-ref %}

Si el Web Service que necesitás no se encuentra en la lista de la documentación, podés llamarlo siguiendo esta guía:

{% content-ref url="/pages/4zlCsTNGo99FZGfrhpZn" %}
[Otro web service](/siguientes-pasos/web-services/otro-web-service.md)
{% endcontent-ref %}

Podés usar la referencia de la API para obtener ejemplos de cómo usar los métodos de todos los web services de ARCA.

{% embed url="<https://afipsdk.com/docs/api-reference/introduction/>" %}

También podés usar las guías del blog de Afip SDK para Java:

{% embed url="<https://afipsdk.com/blog/category/Java/>" %}

Y un proyecto de ejemplo listo para usar:

{% embed url="<https://github.com/AfipSDK/afip-sdk-billing-example-java>" %}

***

### Usar tu propio certificado <sup><sub>(Opcional)<sub></sup>

Primero, obtenemos el certificado siguiendo esta guía.

{% embed url="<https://afipsdk.com/blog/como-obtener-certificado-para-web-services-arca/>" fullWidth="false" %}

Y luego lo agregamos a la instancia de la clase Afip.

{% tabs %}
{% tab title="Main.java" %}
{% code fullWidth="true" %}

```java
import com.afipsdk.Afip;
import com.afipsdk.model.AfipOptions;

AfipOptions options = new AfipOptions();
options.setCuit("20111111112"); // CUIT del certificado
options.setProduction(false);
options.setAccessToken("TU_ACCESS_TOKEN"); // Obtenido de https://app.afipsdk.com
options.setCert("-----BEGIN CERTIFICATE-----MIIDRzC...");
options.setKey("-----BEGIN RSA PRIVATE KEY-----MIIEowIBAAKCA...");

Afip afip = new Afip(options);
```

{% endcode %}
{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.afipsdk.com/integracion/java.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
