Skip to main content

Prerequisites

Before installing the Currency Converter, ensure you have the following:

Java JDK

Java Development Kit 11 or higher

Git

Git for cloning the repository
The application requires Java 11+ because it uses modern features like HttpClient, var, switch expressions with yield, and records.

Verify Java Installation

Check your Java version:
java -version
javac -version
You should see output indicating Java 11 or higher. If not, download and install the latest JDK from Oracle or OpenJDK.

Installation Steps

1

Clone the Repository

Clone the Currency Converter repository to your local machine:
git clone https://github.com/yourusername/currency-converter.git
cd currency-converter
Replace yourusername with the actual GitHub username or organization where the repository is hosted.
2

Verify Project Structure

Ensure the project structure is correct:
ls -la
You should see:
├── lib/
│   └── gson-2.10.1.jar
├── src/
│   └── lad/com/alura/conversormoneda/
├── .gitignore
└── Conversor_de_Moneda_Challenge_ONE_Java_Backend.iml
3

Compile the Application

Compile the Java source files with the Gson dependency:
javac -cp "lib/gson-2.10.1.jar" -d out src/lad/com/alura/conversormoneda/**/*.java
This command:
  • -cp "lib/gson-2.10.1.jar" - Adds Gson library to the classpath
  • -d out - Outputs compiled .class files to the out directory
  • src/lad/com/alura/conversormoneda/**/*.java - Compiles all Java files in the package
If you’re on Windows, use semicolons instead of colons in the classpath: -cp "lib/gson-2.10.1.jar"
4

Verify Compilation

Check that the compilation was successful:
ls out/lad/com/alura/conversormoneda/
You should see the compiled directories:
controladores/
modelos/
vista/

Alternative: Using an IDE

You can also open the project in your favorite Java IDE:
  1. Open IntelliJ IDEA
  2. Select File > Open
  3. Navigate to the project directory and select it
  4. IntelliJ will automatically detect the .iml file
  5. Right-click on lib/gson-2.10.1.jar and select Add as Library
  6. Run the application from ConversorApp.java

Troubleshooting

This error means the Gson library is not in your classpath.Solution: Make sure to include -cp "lib/gson-2.10.1.jar" when compiling and running:
javac -cp "lib/gson-2.10.1.jar" -d out src/lad/com/alura/conversormoneda/**/*.java
java -cp "out:lib/gson-2.10.1.jar" lad.com.alura.conversormoneda.controladores.ConversorApp
Your Java version is too old.Solution: Upgrade to Java 11 or higher. The application uses modern Java features like:
  • java.net.http.HttpClient (Java 11+)
  • Records (Java 14+, used in RegistroConversion)
  • Switch expressions with yield (Java 13+)
The path to source files is incorrect.Solution: Make sure you’re in the project root directory and the src folder exists:
pwd  # Should show the project root
ls src/lad/com/alura/conversormoneda/  # Should list the package directories
The application includes an API key for ExchangeRate-API in the source code. For production use, you should:
  1. Register for your own API key at exchangerate-api.com
  2. Store the key in an environment variable
  3. Load it from configuration instead of hardcoding

Next Steps

Quick Start Guide

Learn how to run the application and perform your first currency conversion

Build docs developers (and LLMs) love