Discord bots2 minutes to read

How do I host a Java Discord bot built with JDA?

Build a runnable JAR for the Java 21 host, choose an allocation that fits JDA and distinguish packaging errors from Discord login errors.

Upload the file the JVM can run

Choose the JDA profile on Bothosting, upload a runnable JAR containing your bot and its dependencies, and set JAR_FILE to the uploaded path. The profile runs Java 21 and requires at least 512 MB of allocated memory. Relay is the first Bothosting plan large enough for that minimum. Heavier bots may need a larger allocation.

If your repository contains Java source and a build script, compile the artifact before upload. A source archive can look complete in Files while still containing nothing the runtime can launch. A thin JAR can start the JVM and then fail as soon as it tries to load JDA.

Build the downloadable example

Extract the JDA example on a machine with Java 21 and Gradle 8.14.3. Run these commands in the directory containing build.gradle. This example writes bot.jar directly in that directory.

Build the archive and inspect its contents
gradle shadowJar
jar tf bot.jar

The listing should include Main.class and dependency classes under net/dv8tion/jda/. The build also sets the manifest’s main class. For your own project, check its output location and entry class before setting the hosted filename.

Check packaging, login and reply separately

Upload the built artifact, set BOT_TOKEN in Variables and start the deployment. A missing main manifest or missing JDA class points back to packaging. A login error means the JVM got far enough to contact Discord, so check which application issued the saved bot token.

In the test server, open the command picker, select this application’s /ping and send it. Receiving pong confirms the hosted bot handled the interaction. If startup or a busy guild reaches the allocation limit, measure peak usage before resizing. The Discord memory guide explains how the allocation fits the account plan.