Search code examples
javaintellij-ideakotlinintellij-pluginintellij-14

Jar File Does Not Run After IntelliJ Upgrade


Expected

Jar file builds and runs with the following configuration described in the section Generate Deployable JAR — Step 3 of 4 in this Medium post and outlined below.

  1. Packaging the application in a JAR File: Project Structure > Project Settings > Artifacts > + > Jar > From modules with dependencies…

    • Module: projectModuleName_main
    • MainClass:YourMainClassWithMainMethod
    • Manifest: src/main/manifestName
    • Output directory: projectName/out/artifacts/jarName_jar
  2. Build and run JAR

    • Build > Build Artifacts… > Action > Build
    • Run Jar: Run > Edit Configurations: + and select JAR Application (Before launch: + > Build Artifacts > artifactName)

Observed

Jar file does not run after upgrading my version of IntelliJ.

Error

Error: Unable to initialize main class Initialization

Caused by: java.lang.NoClassDefFoundError: kotlin/TypeCastException

IntelliJ version

IntelliJ IDEA 2018.3.3 (Community Edition)

Build #IC-183.5153.38, built on January 9, 2019

JRE: 1.8.0_152-release-1343-b26 x86_64

JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o

Mac OS X 10.11.6


Solution

  • Deleting the existing Jar file and going through the steps outlined above Packaging the application in a JAR File and Build and run JAR resolved the issue. The new Jar is now running as expected.