For the complete documentation index, see llms.txt. This page is also available as Markdown.

Java

Install and manage a Java JDK locally (Windows, macOS, Linux) using installers, package managers, or SDKMAN!; build a runnable JAR with Maven or Gradle.

๐Ÿงพ Overview

Java runs on the JVM and is used for Discord bots (JDA, Discord4J), APIs (Spring Boot, Javalin), and background services. A local JDK lets you:

  • Compile and run your project before uploading it to Discloud

  • Manage dependencies with Maven or Gradle

  • Build the runnable .jar that you upload to Discloud

On Discloud, Java applications are uploaded as a pre-built .jar. See Java for hosting details and How to build and package a Java application? for the full build walkthrough.


๐Ÿ“ฅ Installation

Install a JDK (not just a JRE): the JDK includes the javac compiler. The examples below use Eclipse Temurin, a free OpenJDK build. Pick an LTS version (e.g. 21).

1

Open https://adoptium.net/ and download the LTS .msi installer

2

Run the installer and enable Set JAVA_HOME variable and Add to PATH

3

Reopen the terminal and verify

Download the LTS .pkg from adoptium.net, install it, then:


๐Ÿงฐ Build Tools (Maven or Gradle)

Most Java projects use a build tool to download dependencies and produce the .jar. Use the one your project already has (pom.xml = Maven, build.gradle = Gradle).

If the project has a Gradle wrapper (gradlew), you don't need to install Gradle: use ./gradlew (or gradlew.bat on Windows).


๐Ÿงช Minimal Workflow

1

Build the project into a JAR

2

Test the JAR locally before uploading

3

Upload the .jar to Discloud, with MAIN in your discloud.config pointing to it.

The exact JAR name and folder (target/ for Maven, build/libs/ for Gradle) depend on your project. To include the dependencies in a single runnable JAR, see How to build and package a Java application?.


๐Ÿ”„ Updating

Task
Command

Update JDK (SDKMAN!)

sdk upgrade java

Update JDK (Homebrew)

brew upgrade --cask temurin@21

Update JDK (winget)

winget upgrade EclipseAdoptium.Temurin.21.JDK

Check dependency updates (Maven)

mvn versions:display-dependency-updates


๐Ÿ—ƒ Common Commands