Skip to content

IntelliJ IDEA Setup

Download

  1. Navigate to "New Project" from any view
  2. Select Gradle -> Java as the type of Project and make sure the correct JDK is selected (Java 8 or higher)

    new_project

  3. Provide a title for your project and define your GroupId and optionally the ArtifactId and initial Version in the "Artifact Coordinates" subsection

    artifact_setup

  4. Optionally enable Auto-Importing of the Gradle file in the Gradle settings. This is also the place where you could switch the runner for your project (By default, Gradle is used to run your application and tests)

    gradle_settings auto_import

  5. Let IntelliJ index your project.

  6. Open build.gradle
  7. Populate the build file with the following

    plugins {
        id'application'
        id'com.github.johnrengelman.shadow' version '5.2.0'
    }
    
    mainClassName = 'com.example.jda.Bot' // (1)
    
    version '1.0'
    def jdaVersion = 'JDA_VERSION_HERE' // (2)
    
    sourceCompatibility = targetCompatibility = 1.8
    
    repositories {
        mavenCentral()
    }
    
    dependencies {
        implementation("net.dv8tion:JDA:$jdaVersion")
    }
    
    compileJava.options.encoding = 'UTF-8'
    

    1. Replace the mainClassName value with the path to your main class later on!

    2. Replace the JDA_VERSION_HERE with the one mentioned in the latest release

  8. If IntelliJ IDEA didn't already do so automatically, set up a source folder as src/main/java

  9. Create your group package. Example: me.name.bot
  10. Make your main class. Example: Bot.java. Your directory tree should look like this:
    ProjectName -> src/main/java -> me/name/bot -> Bot.java
                -> gradle/wrapper -> gradle-wrapper.properties
                -> gradle/wrapper -> gradle-wrapper.jar
                -> build.gradle
                -> settings.gradle
    
  11. Configure the mainClassName value in the build.gradle to your class. Example: me.name.bot.Bot
  12. To build your finished project simply use the shadowJar task in your Gradle tool window on right hand side of your editor. This will build a jar in build/libs. The one with the -all suffix is the shadow jar. > You can also run your project with the run Gradle task!
  13. Setup Logback
  14. Continue with Getting Started
  1. Open the Project view
  2. Create a new Project

    project

  3. Select Gradle > Java

  4. Configure your SDK to use Java 1.8

    gradle

  5. Click Next and fill in your groupId and your artifactId. Example: me.name and bot

    artifact

  6. Check Use auto-import and click Next > Finish

    settings