Black Friday: first month 50% off on monthly plans, or your first month free when you pay per quarter. Until Monday 30 November 23:59. See the plans Conditions
New customers: first month 50% off monthly plans, until 30 Nov
New here? Try a Minecraft server or Discord bot free for 24 hours. Try free
ServerSparkServerSpark

Knowledge base

Java Discord bot (JDA) hosting: run it 24/7 on a VPS

Why a JDA, Javacord or Discord4J bot needs a VPS instead of a bot plan, and how to run it 24/7 with Java and systemd step by step.

NVMe nodesNightly backupsOnline in minutes

Updated 30 November 2026

A Discord bot written in Java, with JDA, Javacord or Discord4J, does not run on our Discord bot hosting plans: those plans run Node.js or Python, and Java is not installed there. A Java bot runs on a VPS, where you install Java yourself and keep the bot online 24/7 with systemd. This guide shows what to pick and how to set it up.

Which option fits your bot?

  • Your bot is in Java (JDA, Javacord, Discord4J) or you run Lavalink yourself: a VPS. You get root access and can install any Java version.
  • You can choose the language: discord.js or discord.py run on the bot plans without any server work, with packages installed for you and code from GitHub. See discord.js bot hosting and Python Discord bot hosting.
  • A music bot in Node.js or Python that uses Lavalink: the bot can run on a bot plan and connect to a Lavalink server elsewhere. See Discord music bot hosting with Lavalink.

Run a JDA bot on a VPS

  1. Build one jar with all dependencies, for example with the Gradle Shadow plugin (./gradlew shadowJar) or the Maven Shade plugin. Test it on your PC with java -jar bot.jar.
  2. Install Java on the VPS. On Ubuntu 24.04: sudo apt install openjdk-21-jre-headless. Use the Java version your build targets; JDA 5 needs Java 8 or newer.
  3. Make a user and folder: sudo useradd -r -m -d /opt/mybot mybot, then copy bot.jar to /opt/mybot (for example with scp).
  4. Store the token in /opt/mybot/.env as DISCORD_TOKEN=your-token, readable only by the bot user (chmod 600). In your code read it with System.getenv("DISCORD_TOKEN").
  5. Make a systemd service in /etc/systemd/system/mybot.service:
    [Unit]
    Description=My Discord bot
    After=network-online.target
    
    [Service]
    User=mybot
    WorkingDirectory=/opt/mybot
    EnvironmentFile=/opt/mybot/.env
    ExecStart=/usr/bin/java -Xmx512m -jar /opt/mybot/bot.jar
    Restart=always
    RestartSec=5
    
    [Install]
    WantedBy=multi-user.target
  6. Start it: sudo systemctl daemon-reload and sudo systemctl enable --now mybot. The bot now starts again after a crash or a reboot. Logs: journalctl -u mybot -f.
-Xmx sets the most memory Java may use. A typical JDA bot is fine with 256 to 512 MB; raise it for big caches or many servers, and leave room for the operating system.

Updating your bot

Build a new jar, copy it over the old one and run sudo systemctl restart mybot. Want updates from GitHub? Clone the repository in /opt/mybot, and build and restart with a short script after git pull. The same steps for Node.js and Python bots are in Run a Discord bot 24/7 on a VPS with systemd.

Frequently asked questions

Can I host a JDA bot on a ServerSpark bot hosting plan? No. The bot plans run Node.js or Python and Java is not installed there. Use a VPS for a Java bot.

How much memory does a JDA bot need? A typical bot runs with 256 to 512 MB for Java. Bots in many servers or with large member caches need more.

Which Java version should I use? The one your project is built for. Java 21 is a long-term support version that works with current JDA releases.

How do I keep a Java Discord bot online 24/7? Run it as a systemd service with Restart=always, so it starts again after a crash and after a reboot.