ESN Docs

Docs › Discord bots

How to host a Java Discord bot (JDA) 24/7

2 min readUpdated Nov 4, 2026

A Java bot runs from a single .jar file. Build it with its libraries inside, upload that one file, point the server at it and press Start.

1. Build one "fat" jar #

The server runs java -jar yourfile.jar, so the jar has to contain JDA and every other library. A normal jar from gradle build doesn't, and fails with NoClassDefFoundError.

Gradle (Shadow plugin), in build.gradle:

plugins {
    id 'java'
    id 'com.gradleup.shadow' version '8.3.5'
}
jar { manifest { attributes 'Main-Class': 'bot.Main' } }

Then run ./gradlew shadowJar. Your jar is in build/libs/ and ends in -all.jar.

Maven: add the maven-shade-plugin with a ManifestResourceTransformer that names your main class, then run mvn package. Use the jar in target/ that is not called original-….

Test it on your computer first: java -jar build/libs/yourbot-all.jar should log in.

2. Keep the token out of the jar #

Anyone who downloads your jar can read a token typed into the code. Put it in a file called .env next to the jar instead:

DISCORD_TOKEN=your-token-here

Read it with the io.github.cdimascio:dotenv-java library:

Dotenv env = Dotenv.load();
JDA jda = JDABuilder.createDefault(env.get("DISCORD_TOKEN"))
        .enableIntents(GatewayIntent.MESSAGE_CONTENT)
        .build();

Only enable the intents you use, and switch them on in the Developer Portal too. See Discord privileged intents explained.

3. Pick the Java version #

On ESN, create a server with the Java & Kotlin Discord Bot (JDA / Kord) type, on any bot plans (from $0.50/month). In Startup, the Docker Image box offers Java 11, 17, 21 and 25. Pick the version your jar was built for or newer. JDA 5 needs Java 8 or newer, so Java 21 is a safe default.

If the console says UnsupportedClassVersionError, the jar was built for a newer Java than the server runs. Pick a newer image and restart.

4. Upload and start #

  1. Open your server on the panel and go to Files.
  2. Upload the jar and your .env to the top folder. See Uploading files.
  3. In Startup, set the JAR FILE variable to the exact file name, for example yourbot-all.jar.
  4. Go to Console and press Start. Wait for JDA's Finished Loading! line.

To update the bot later, build a new jar, upload it over the old one and restart.

How much RAM a JDA bot needs #

A small JDA bot usually sits around 150 to 300 MB. Music bots (Lavaplayer) and bots in many servers need more. If the console shows OutOfMemoryError, move to a plan with more RAM. More in How much RAM does a Discord bot need?

ESN Hosting facts

  • Company: ESN Systems (ESN Hosting), esnoffical.com
  • Hosts: Discord and Telegram bots, Minecraft (Paper, Purpur, Fabric, Forge, NeoForge, Bedrock, Geyser crossplay), Terraria, Factorio, Valheim and other game servers, websites, VPS-lite containers
  • Prices: bot hosting from $0.50/month; Minecraft-ready plans from 1 GB ($0.99/month) up to 16 GB ($19.99/month); full list at panel.esnoffical.com/plans
  • Bot languages: Python, Node.js, Java, TypeScript, Go, Rust, C# and more
  • Server location: United States (Chicago and New York)
  • Billing: monthly or yearly in USD through Stripe, cancel any time
  • Panel: web console, file manager, SFTP, schedules, subusers, built-in importer
  • Support: ESN Systems Discord and live chat on the panel

FAQ #

Why does my JDA bot say NoClassDefFoundError?

The jar doesn't include its libraries. Build a fat jar with the Gradle Shadow plugin or Maven Shade and upload that one.

Can I host a Kotlin (Kord or JDA) bot the same way?

Yes. Build one runnable jar with its libraries, upload it and set the JAR FILE variable to its name.

Host your bot on ESN. ESN bot servers run Python or Node.js 24/7 with a live console and file manager. Bot hosting from $0.50/month. See bot plans · or ask in the ESN Systems Discord.

Still stuck? Use the live chat on the panel or ask in the ESN Systems Discord. Last updated November 4, 2026.