A comprehensive technical reference for compiling, uploading, and managing JVM-based Discord bots built with the Java Discord API (JDA).
To host a Java bot on a Pterodactyl container, you must compile your project into a single executable **Fat Jar** containing all dependencies.
plugins {
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'java'
}
dependencies {
implementation 'net.dv8tion:JDA:5.0.0-beta.20'
}
shadowJar {
archiveBaseName.set('my-jda-bot')
archiveClassifier.set('')
archiveVersion.set('')
}Run the command ./gradlew shadowJar or mvn package to generate your executable jar.
Upload the compiled my-jda-bot.jar directly to your Pterodactyl server root via SFTP or the web file manager.
Java requires specific JVM heap limits configured so the kernel doesn't terminate the process if it goes over container memory limits.
java -Xms512M -Xmx1536M -XX:+UseG1GC -jar my-jda-bot.jar
Set the **Server Jar File** startup variable to my-jda-bot.jar, and set custom JVM flags in the panel settings tab. Memory requirements are highly code-dependent. Your actual allocation needs will vary based on command cache size, external libraries (e.g. databases, lavalink), and active shard counts. Always monitor your container's memory metrics in the console to scale your plan or adjust JVM flags appropriately.
This happens if the JVM allocates more memory than permitted by the `-Xmx` flag. **Remediation:** Stop the server and adjust the JVM heap limits. Keep a margin of 25% for overhead, for example, for a 2GB RAM node set `-Xmx1536M` to allow 512MB for metspace/thread overhead.
This happens if your jar was compiled with a newer Java version (e.g. Java 21) than configured in the Pterodactyl environment. **Remediation:** Change your container environment Java version in the Startup tab to match your build version (JDK 17 or 21).