title: Installing Kotlin-Jupyter: e: java.lang.NoClassDefFoundError: Could not initialize class org.jetbrains.kotlin.com.intellij.pom.java.LanguageLevel
body: <p>I'm new to gradle, but recently I wanted to use Kotlin-Jupyter notebook for a project.</p>
  <p>I followed the instructions, I cloned the repo at <a href="https://github.com/Kotlin/kotlin-jupyter" rel="noreferrer">https://github.com/Kotlin/kotlin-jupyter</a>...</p>
  <p>Throughout my struggles, I have gone through a whopping 5-6 errors, all of which have taken days on end to fix. It has quite literally been a nightmare.</p>
  <p>I am getting this new error when typing in the command <code>gradlew install</code>, it is an internal exception:</p>
  <pre><code>
  &gt; Task :kotlin-jupyter-publish:compileKotlin FAILED
  The `kotlin-dsl` plugin applied to project ':kotlin-jupyter-publish' enables experimental Kotlin compiler features. For more information see https://docs.gradle.org/6.8.2/userguide/kotlin_dsl.html#sec:kotlin-dsl_plugin
  e: java.lang.NoClassDefFoundError: Could not initialize class org.jetbrains.kotlin.com.intellij.pom.java.LanguageLevel
          at org.jetbrains.kotlin.com.intellij.core.CoreLanguageLevelProjectExtension.&lt;init&gt;(CoreLanguageLevelProjectExtension.java:26)
          at org.jetbrains.kotlin.com.intellij.core.JavaCoreProjectEnvironment.&lt;init&gt;(JavaCoreProjectEnvironment.java:42)
          at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreProjectEnvironment.&lt;init&gt;(KotlinCoreProjectEnvironment.kt:26)
          at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$ProjectEnvironment.&lt;init&gt;(KotlinCoreEnvironment.kt:118)
          at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.createForProduction(KotlinCoreEnvironment.kt:420)
          at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.createCoreEnvironment(K2JVMCompiler.kt:226)
          at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:152)
          at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:52)
          at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:88)
          at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:44)
          at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:98)
          at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:371)
          at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:105)
          at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally(IncrementalCompilerRunner.kt:249)
          at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.access$compileIncrementally(IncrementalCompilerRunner.kt:38)
          at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner$compile$2.invoke(IncrementalCompilerRunner.kt:80)
          at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:92)
          at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:602)
          at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:93)
          at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1644)
          at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
          at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.base/java.lang.reflect.Method.invoke(Method.java:567)
          at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357)
          at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
          at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
          at java.base/java.security.AccessController.doPrivileged(AccessController.java:691)
          at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
          at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:587)
          at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:828)
          at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:705)
          at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
          at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:704)
          at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
          at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
          at java.base/java.lang.Thread.run(Thread.java:831)
  
  
  FAILURE: Build failed with an exception.
  
  * What went wrong:
  Execution failed for task ':kotlin-jupyter-publish:compileKotlin'.
  &gt; Internal compiler error. See log for more details
  
  * Try:
  Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
  
  * Get more help at https://help.gradle.org
  
  BUILD FAILED in 1s
  </code></pre>
  <p>Yes, it is quite long. I am unsure what the cause of the error is - to be quite frank, I'm a bit of a noob when it comes to Gradle. I was wondering why I am getting this error and how I could fix this so I can proceed with my project.</p>
  <p>Again, just recently I installed the JDK and set the environment variable for the JDK. I am not sure if the error has risen because of this, if so - here is my environment variable, maybe I have set it wrong:</p>
  <p><code>C:\Program Files\Java\jdk-16</code></p>
  <p>Also this is the gradle properties file:</p>
  <pre><code># kotlinVersion=1.4.255-SNAPSHOT
  kotlinVersion=1.4.31
  kotlinLanguageLevel=1.4
  jvmTarget=1.8
  
  shadowJarVersion=5.2.0
  kotlinxSerializationVersion=1.1.0
  ktlintGradleVersion=9.4.1
  ktlintVersion=0.40.0
  junitVersion=5.6.2
  slf4jVersion=1.7.30
  khttpVersion=1.0.0
  http4kVersion=4.4.0.1
  artifactsPath=build/artifacts
  
  baseVersion=0.8.3
  
  projectRepoUrl=https://github.com/Kotlin/kotlin-jupyter
  docsRepo=git@github.com:ileasile/kotlin-jupyter-docs.git
  pushRepoUrl=git@github.com:Kotlin/kotlin-jupyter.git
  
  jupyterApiVersion=0.8.3.291
  kotlin.jupyter.add.api=false
  kotlin.jupyter.add.scanner=false
  
  org.gradle.jvmargs=-Xmx512M
  </code></pre>
  <p>Also build.gradle file:</p>
  <pre><code>import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
  import org.jetbrains.kotlinx.jupyter.build.getFlag
  import org.jetbrains.kotlinx.jupyter.plugin.options
  import org.jetbrains.kotlinx.jupyter.publishing.addPublication
  import org.jetbrains.kotlinx.jupyter.publishing.applyNexusPlugin
  import org.jlleitschuh.gradle.ktlint.KtlintExtension
  
  plugins {
      kotlin(&quot;jvm&quot;)
      kotlin(&quot;jupyter.api&quot;) apply false
      kotlin(&quot;plugin.serialization&quot;)
      id(&quot;com.github.johnrengelman.shadow&quot;)
      id(&quot;org.jlleitschuh.gradle.ktlint&quot;)
      id(&quot;org.jetbrains.kotlinx.jupyter.dependencies&quot;)
      id(&quot;org.jetbrains.kotlinx.jupyter.publishing&quot;)
      id(&quot;org.jetbrains.kotlinx.jupyter.doc&quot;)
  }
  
  extra[&quot;isMainProject&quot;] = true
  
  val kotlinxSerializationVersion: String by project
  val ktlintVersion: String by project
  val junitVersion: String by project
  val slf4jVersion: String by project
  val khttpVersion: String by project
  
  val docsRepo: String by project
  
  val taskOptions = project.options()
  val deploy: Configuration by configurations.creating
  
  deploy.apply {
      exclude(&quot;org.jetbrains.kotlinx&quot;, &quot;kotlinx-serialization-json-jvm&quot;)
      exclude(&quot;org.jetbrains.kotlinx&quot;, &quot;kotlinx-serialization-core-jvm&quot;)
  }
  
  applyNexusPlugin()
  
  fun KtlintExtension.setup() {
      version.set(ktlintVersion)
      enableExperimentalRules.set(true)
  }
  
  ktlint {
      setup()
  }
  
  subprojects {
      apply(plugin = &quot;org.jlleitschuh.gradle.ktlint&quot;)
  
      ktlint {
          setup()
      }
  }
  
  allprojects {
      val kotlinLanguageLevel: String by rootProject
      val jvmTarget: String by rootProject
  
      tasks.withType(KotlinCompile::class.java).all {
          kotlinOptions {
              languageVersion = kotlinLanguageLevel
              this.jvmTarget = jvmTarget
          }
      }
  }
  
  dependencies {
      // Dependency on module with compiler.
      api(project(&quot;:shared-compiler&quot;))
  
      // Standard dependencies
      implementation(kotlin(&quot;stdlib&quot;))
      implementation(kotlin(&quot;reflect&quot;))
      implementation(kotlin(&quot;stdlib-jdk8&quot;))
      implementation(&quot;org.jetbrains:annotations:20.1.0&quot;)
      implementation(&quot;org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2&quot;)
  
      // Embedded compiler and scripting dependencies
      implementation(kotlin(&quot;compiler-embeddable&quot;))
      implementation(kotlin(&quot;scripting-compiler-impl-embeddable&quot;))
      implementation(kotlin(&quot;scripting-compiler-embeddable&quot;))
      implementation(kotlin(&quot;scripting-ide-services&quot;))
      implementation(kotlin(&quot;main-kts&quot;))
      implementation(kotlin(&quot;script-util&quot;))
      implementation(kotlin(&quot;scripting-common&quot;))
  
      // Embedded version of serialization plugin for notebook code
      implementation(kotlin(&quot;serialization&quot;))
  
      // Logging
      implementation(&quot;org.slf4j:slf4j-api:$slf4jVersion&quot;)
      runtimeOnly(&quot;org.slf4j:slf4j-simple:$slf4jVersion&quot;)
  
      // ZeroMQ library for implementing messaging protocol
      implementation(&quot;org.zeromq:jeromq:0.5.2&quot;)
  
      // Clikt library for parsing output magics
      implementation(&quot;com.github.ajalt:clikt:2.8.0&quot;)
  
      // Serialization implementation for kernel code
      implementation(&quot;org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlinxSerializationVersion&quot;)
  
      // Test dependencies: kotlin-test and Junit 5
      testImplementation(kotlin(&quot;test&quot;))
      testImplementation(&quot;org.junit.jupiter:junit-jupiter-api:$junitVersion&quot;)
      testImplementation(&quot;io.kotlintest:kotlintest-assertions:3.1.6&quot;)
  
      testRuntimeOnly(&quot;org.junit.jupiter:junit-jupiter-engine:$junitVersion&quot;)
  
      deploy(project(&quot;:lib&quot;))
      deploy(project(&quot;:api&quot;))
      deploy(kotlin(&quot;script-runtime&quot;))
  }
  
  tasks.register(&quot;publishLocal&quot;) {
      group = &quot;publishing&quot;
  
      dependsOn(
          tasks.condaPackage,
          tasks.pyPiPackage
      )
  }
  
  tasks.named(&quot;closeRepository&quot;) {
      mustRunAfter(&quot;publishToSonatype&quot;)
  }
  
  tasks.register(&quot;publishToSonatypeAndRelease&quot;) {
      group = &quot;publishing&quot;
  
      dependsOn(&quot;publishToSonatype&quot;, &quot;closeAndReleaseRepository&quot;)
  }
  
  tasks.register(&quot;publishToPluginPortal&quot;) {
      group = &quot;publishing&quot;
  
      dependsOn(
          &quot;:kotlin-jupyter-api-gradle-plugin:publishPlugins&quot;
      )
  }
  
  tasks.jar {
      manifest {
          attributes[&quot;Main-Class&quot;] = taskOptions.mainClassFQN
          attributes[&quot;Implementation-Version&quot;] = project.version
      }
  }
  
  tasks.shadowJar {
      archiveBaseName.set(taskOptions.packageName)
      archiveClassifier.set(&quot;&quot;)
      mergeServiceFiles()
  
      manifest {
          attributes(tasks.jar.get().manifest.attributes)
      }
  }
  
  tasks.test {
      val doParallelTesting = getFlag(&quot;test.parallel&quot;, true)
  
      /**
       *  Set to true to debug classpath/shadowing issues, see testKlaxonClasspathDoesntLeak test
       */
      val useShadowedJar = getFlag(&quot;test.useShadowed&quot;, false)
  
      useJUnitPlatform()
      testLogging {
          events(&quot;passed&quot;, &quot;skipped&quot;, &quot;failed&quot;)
      }
  
      if (useShadowedJar) {
          dependsOn(tasks.shadowJar.get())
          classpath = files(tasks.shadowJar.get()) + classpath
      }
  
      systemProperties = mutableMapOf(
          &quot;junit.jupiter.displayname.generator.default&quot; to &quot;org.junit.jupiter.api.DisplayNameGenerator\$ReplaceUnderscores&quot;,
  
          &quot;junit.jupiter.execution.parallel.enabled&quot; to doParallelTesting.toString() as Any,
          &quot;junit.jupiter.execution.parallel.mode.default&quot; to &quot;concurrent&quot;,
          &quot;junit.jupiter.execution.parallel.mode.classes.default&quot; to &quot;concurrent&quot;
      )
  }
  
  tasks.processResources {
      dependsOn(tasks.buildProperties)
  }
  
  tasks.check {
      dependsOn(tasks.checkReadme)
  }
  
  tasks.publishDocs {
      docsRepoUrl.set(docsRepo)
  }
  
  addPublication {
      publicationName = &quot;kernel&quot;
      artifactId = &quot;kotlin-jupyter-kernel&quot;
      description = &quot;Kotlin Jupyter kernel published as artifact&quot;
      packageName = artifactId
  }
  </code></pre>
  <p>Thanks,</p>
  <p>Tom Joney</p>