0

I am trying to run a jar file using the command java -jar Parser/build/libs/CSVParser-1.0-SNAPSHOT.jar but it is showing me an exception

Exception in thread "main" java.lang.NoClassDefFoundError: kotlin/Pair
   at server.MainKt.main(Main.kt:16)
   at server.MainKt.main(Main.kt)
Caused by: java.lang.ClassNotFoundException: kotlin.Pair
   at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
   at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
   at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
   ... 2 more

This is what the MANIFEST.MF looks like

Manifest-Version: 1.0
Main-Class: server.MainKt

I think it's not able to find the class defined at line number 16 of the file.

build.gradle

plugins {
    id 'org.jetbrains.kotlin.jvm' version '1.5.10'
}
apply plugin: 'application'


group 'org.example'
version '1.0-SNAPSHOT'

repositories {
    mavenCentral()
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib"
    implementation 'com.google.code.gson:gson:2.9.0'
    implementation 'org.json:json:20220320'

    testImplementation "org.junit.jupiter:junit-jupiter-engine:5.8.2"
    testImplementation "org.junit.jupiter:junit-jupiter-api:5.8.2"
    testImplementation 'org.mockito:mockito-core:4.4.0'
    testImplementation "org.junit.jupiter:junit-jupiter-params"
}


test{
    useJUnitPlatform()
}

application{
    mainClassName = 'server.MainKt'
}

Main.kt

package server

import getResponse.BadRequest
import getResponse.FileContent
import getResponse.GetResponse
import getResponse.HomePath
import httpmethods.GetMethod
import httpmethods.PostMethod
import postResponse.GenerateErrors
import postResponse.GenerateHeaders
import postResponse.PostResponse

fun main() {
    val mapOfGetPaths: Map<String, GetResponse> =
        mapOf(
            "" to BadRequest(),
            "/" to HomePath(),
            "/main.css" to FileContent(),
            "/js/main.js" to FileContent(),
            "/config.html" to FileContent(),
            "/js/config.js" to FileContent(),
            "/js/error.js" to FileContent(),
            "/error.html" to FileContent(),
            "/js/convert.js" to FileContent(),
            "/js/configHtmlElements.js" to FileContent()
        )
    val mapOfPostPaths: Map<String, PostResponse> =
        mapOf(
            "" to postResponse.BadRequest(),
            "/csv" to GenerateHeaders(),
            "/configSet" to GenerateErrors()
        )

    val getMethod = GetMethod(mapOfGetPaths)
    val postMethod = PostMethod(mapOfPostPaths)

    Server(3000, getMethod, postMethod).listenForRequests()
}

BadRequest, HomePath, FileContent, GenrateErrors, GetMethod, PostMethod, are classes from different Packages

ZKXDXD
  • 1
  • 2

0 Answers0