Skip to main content
The Currency Converter has minimal dependencies and uses manual compilation without build tools like Maven or Gradle.

External Dependencies

Gson 2.10.1

Location: lib/gson-2.10.1.jar Purpose: JSON parsing and serialization for API responses Usage: The ConsultaMoneda class uses Gson to parse JSON responses from the ExchangeRate-API:
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;

// Parsing API response
JsonElement elemento = JsonParser.parseString(respuesta.body());
JsonObject objectRoot = elemento.getAsJsonObject();
return objectRoot.get("conversion_result").getAsDouble();
Why Gson?
  • Lightweight and reliable
  • Simple API for parsing JSON
  • No additional dependencies
  • Widely used in Java projects

Java Standard Library

The application relies on several Java standard library packages:

HTTP Client (java.net.http)

Introduced: Java 11 Usage: Making HTTP requests to the ExchangeRate-API
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

HttpClient cliente = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create(url))
    .GET()
    .build();
Referenced in: src/lad/com/alura/conversormoneda/modelos/ConsultaMoneda.java:6-9

Scanner (java.util)

Usage: Reading user input from console
import java.util.Scanner;

Scanner sc = new Scanner(System.in);
int opcion = sc.nextInt();
double cantidad = sc.nextDouble();
Referenced in: src/lad/com/alura/conversormoneda/controladores/ConversorApp.java:10

LocalDateTime (java.time)

Usage: Timestamping conversion history records
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

RegistroConversion registro = new RegistroConversion(
    base, objetivo, cantidad, resultado, LocalDateTime.now()
);
Referenced in: src/lad/com/alura/conversormoneda/controladores/ConversorApp.java:7

Collections (java.util)

Usage: Managing conversion history
import java.util.ArrayList;
import java.util.List;

List<RegistroConversion> historial = new ArrayList<>();
Referenced in: src/lad/com/alura/conversormoneda/controladores/ConversorApp.java:8-9

No Build Tool Required

This project intentionally does not use Maven or Gradle. It demonstrates pure Java compilation with manual dependency management.

Why No Build Tool?

  • Educational simplicity: Focus on Java fundamentals
  • Minimal setup: No build configuration files needed
  • Single dependency: Only Gson JAR required
  • Transparent process: See exactly what happens during compilation

Comparison with Build Tools

AspectManual CompilationMaven/Gradle
Setup complexityMinimalRequires build file
Dependencies1 JAR fileAutomatic download
Learning curveLowMedium-High
Build reproducibilityManualAutomated
Best forLearning, small projectsProduction, large teams

Updating Gson

If you need to update Gson to a newer version:
1
Download the new version
2
Visit the Gson releases page and download the desired JAR file.
3
Replace the JAR file
4
cd source/lib
rm gson-2.10.1.jar
# Copy your new gson-X.X.X.jar to this directory
5
Update compilation commands
6
Modify the classpath in your build commands:
7
javac -cp "lib/gson-X.X.X.jar" -d out src/lad/com/alura/conversormoneda/**/*.java
java -cp "out:lib/gson-X.X.X.jar" lad.com.alura.conversormoneda.controladores.ConversorApp
8
Test the application
9
Run the application and verify all conversions work correctly.
Gson maintains backward compatibility across minor versions. Updating from 2.10.1 to 2.10.x should be seamless.

Dependency Verification

Verify the Gson JAR is present:
ls -lh source/lib/gson-2.10.1.jar
Expected output: ~277 KB file size

API Dependency

External Service: ExchangeRate-API (v6) Endpoint: https://v6.exchangerate-api.com/v6/ Usage: Real-time currency conversion rates
The application requires an active internet connection to fetch current exchange rates. The API key is embedded in the source code for demonstration purposes.
Referenced in: src/lad/com/alura/conversormoneda/modelos/ConsultaMoneda.java:17

Build docs developers (and LLMs) love