https://kotlinlang.org logo
#ktor
Title
# ktor
m

mudasar187

11/22/2023, 8:32 AM
Hi! I have a Ktor/Gradle application where I am trying to connect to DB2 database. Its expect
db2jcc_license_cisuz.jar
, but where in IntelliJ can i add this license so i can run the application locally from Intellij?
a

Aleksei Tirman [JB]

11/22/2023, 9:16 AM
You may find this answer helpful.
m

mudasar187

11/22/2023, 9:43 AM
Not working 😞 When I add it this way and on kubernetes in Google Cloud it works fine
Copy code
tasks {
    named<Jar>("jar") {
        archiveBaseName.set("app")
        manifest {
            attributes["Main-Class"] = "no.nav.sokos.app.ApplicationKt"
            attributes["Class-Path"] =
                configurations.runtimeClasspath.get().joinToString(separator = " ") {
                    it.name
                }.plus("/var/run/secrets/db2license/db2jcc_license_cisuz.jar")
        }
        doLast {
            configurations.runtimeClasspath.get().forEach {
                val fileProvider: Provider<RegularFile> = layout.buildDirectory.file("libs/${it.name}")
                val targetFile = File(fileProvider.get().toString())
                if (!targetFile.exists()) {
                    it.copyTo(targetFile)
                }
            }
        }
    }
}
But when run locally on my machine it cant find the file, even if i change the path file is to on my computer path.
a

Aleksei Tirman [JB]

11/22/2023, 9:51 AM
Can you check that the command, which IntelliJ IDEA executes, contains the
-cp
flag with the path of the JAR?
m

mudasar187

11/22/2023, 9:55 AM
Ah, you mean this?
Change to ?
a

Aleksei Tirman [JB]

11/22/2023, 9:55 AM
I mean the command in the
Run
panel.
m

mudasar187

11/22/2023, 9:57 AM
CleanShot 2023-11-22 at 10.57.43.png
this one?
a

Aleksei Tirman [JB]

11/22/2023, 9:58 AM
Yes
m

mudasar187

11/22/2023, 9:58 AM
no -cp command here
a

Aleksei Tirman [JB]

11/22/2023, 10:01 AM
If I understand the problem correctly, you need configure the IDEA to make the
-cp
flag added. For more information please read the documentation.