How do I add dependencies (kotlin)

How do I add dependencies, e.g., jar files or gradle dependencies so I have access to libraries like OpenCSV or Jackson (JSON serialization)?

I’m supposed to click the environment button on the left-hand side but when I do nothing happens. Is that Kotlin specific?

I sort of figured out one approach which is to upload the jar files as files and then include them using something like:


but there’s something weird going on with the class loaders because if there’s dependencies between them they they don’t see each other. For instance this works;

import org.apache.commons.lang3.ObjectUtils

but then this fails and says that the opencsv package can’t see the lang3 packages.



import com.opencsv.*


val file = File ("/data/notebook_files/salary.csv")

val csvReader = CSVReaderBuilder(file.reader ()).withSkipLines(2).build()

val allData = csvReader.readAll()


java.lang.NoClassDefFoundError: org/apache/commons/lang3/ObjectUtils
	at com.opencsv.CSVParserBuilder.withErrorLocale(
	at com.opencsv.CSVReaderBaseBuilder.getOrCreateCsvParser(
	at Line_50.<init>(Line_50.jupyter-kts:9)

Hi! Each dependency exists in its separate classloader, and that’s the reason dependencies don’t see each other.

The best and easiest way to achieve what you want is to use maven coordinates for your libraries:

Corresponding coordinates could be easily found on Maven Search portal:

Also, refer to Kotlin kernel Readme: