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. Let IntelliJ index your project.

  4. Open build.gradle.kts

  5. Populate the build file with the following

    plugins {
        application
        id("com.gradleup.shadow") version "8.3.1"
    }
    
    application.mainClass = "com.example.discordbot.Bot" // (1)
    group = "org.example"
    version = "1.0"
    
    val jdaVersion = "JDA_VERSION_HERE" // (2)
    
    repositories {
        mavenCentral()
    }
    
    dependencies {
        implementation("net.dv8tion:JDA:$jdaVersion")
    }
    
    tasks.withType<JavaCompile> {
        options.encoding = "UTF-8"
        options.isIncremental = true
    
        // Set this to the version of java you want to use,
        // the minimum required for JDA is 1.8
        sourceCompatibility = "1.8"
    }
    

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

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

  6. Reload Gradle and wait for it to finish

    reload gradle

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

  8. Create your group package. Example: com.example.discordbot
  9. Make your main class. Example: Bot.java. Your directory tree should look like this:
    ProjectName -> src/main/java -> com/example/discordbot -> Bot.java
                -> gradle/wrapper -> gradle-wrapper.properties
                -> gradle/wrapper -> gradle-wrapper.jar
                -> build.gradle.kts
                -> settings.gradle.kts
    
  10. Configure the mainClass value in the build.gradle.kts to your class. Example: com.example.discordbot.Bot
  11. To build your finished project simply use the shadowJar task in your Gradle tool window on right hand side of your editor. > You can also run your project with the run Gradle task!

    shadowjar

  12. This will build a jar in build/libs. The one with the -all suffix is the shadow jar.

    jar location

  13. Setup Logback

  14. Continue with Getting Started
  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. Let IntelliJ index your project.

    indexing

  4. Open build.gradle.kts

  5. Populate the build file with the following

    plugins {
        application
        id("com.gradleup.shadow") version "8.3.1"
    }
    
    application.mainClass = "com.example.discordbot.Bot" // (1)
    group = "org.example"
    version = "1.0"
    
    val jdaVersion = "JDA_VERSION_HERE" // (2)
    
    repositories {
        mavenCentral()
    }
    
    dependencies {
        implementation("net.dv8tion:JDA:$jdaVersion")
    }
    
    tasks.withType<JavaCompile> {
        options.encoding = "UTF-8"
        options.isIncremental = true
    
        // Set this to the version of java you want to use,
        // the minimum required for JDA is 1.8
        sourceCompatibility = "1.8"
    }
    

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

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

  6. Reload Gradle and wait for it to finish

    reload gradle

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

  8. Create your group package. Example: com.example.discordbot
  9. Make your main class. Example: Bot.java. Your directory tree should look like this:
    ProjectName -> src/main/java -> com/example/discordbot -> Bot.java
                -> gradle/wrapper -> gradle-wrapper.properties
                -> gradle/wrapper -> gradle-wrapper.jar
                -> build.gradle.kts
                -> settings.gradle.kts
    
  10. Configure the mainClass value in the build.gradle.kts to your class. Example: com.example.discordbot.Bot
  11. To build your finished project simply use the shadowJar task in your Gradle tool window on right hand side of your editor. > You can also run your project with the run Gradle task!

    shadowjar

  12. This will build a jar in build/libs. The one with the -all suffix is the shadow jar.

    jar location

  13. Setup Logback

  14. Continue with Getting Started