Kaj Koivunen
01/14/2023, 7:56 PMsrc
main
kotlin
*.kt
resources
file.txt
prior to this, just "file.txt" worked.Chris Lee
01/14/2023, 8:08 PMephemient
01/14/2023, 8:24 PMKaj Koivunen
01/14/2023, 8:28 PMKaj Koivunen
01/14/2023, 8:28 PMChris Lee
01/14/2023, 8:28 PMTry moving file.txt into a directory structure reflecting the package (and access as “file.txt) or access as “/file.txt”.
Chris Lee
01/14/2023, 8:28 PMKaj Koivunen
01/14/2023, 8:29 PMChris Lee
01/14/2023, 8:29 PMKaj Koivunen
01/14/2023, 8:30 PMephemient
01/14/2023, 8:31 PMsrc/main/resources/com/example/app/file.txt
as the documentation clearly states that .
is replaced by /
when constructing the pathChris Lee
01/14/2023, 8:31 PMcom/example/app
would be the folder. Alternately, the resources can go in any folder structure (including how you have it today), and be referenced by their absolute path /file.txt
or /whatever/file.txt
.Kaj Koivunen
01/14/2023, 8:33 PMephemient
01/14/2023, 8:34 PMChris Lee
01/14/2023, 8:34 PMsrc/main/resources
contains resources that are bundled in the root of the jar.ephemient
01/14/2023, 8:35 PMChris Lee
01/14/2023, 8:35 PM/config.properties
still floating around out there in random libraries…Kaj Koivunen
01/14/2023, 8:36 PMsrc/main/resources
is this path specified by something in the build system or is it the same for all projects?Chris Lee
01/14/2023, 8:37 PMephemient
01/14/2023, 8:37 PMKaj Koivunen
01/14/2023, 8:37 PMKaj Koivunen
01/14/2023, 8:38 PMKaj Koivunen
01/14/2023, 8:39 PMephemient
01/14/2023, 8:39 PMephemient
01/14/2023, 8:41 PMAdam S
01/14/2023, 8:41 PMsrc/main/kotlin/main.kt
, but the contents
package my.cool.project
fun main() { ... }
and IntellijJ’s cool with it (so long as all other .kt files in the directory have the same package)Kaj Koivunen
01/14/2023, 8:41 PMChris Lee
01/14/2023, 8:42 PMJavier
01/14/2023, 8:42 PMJavier
01/14/2023, 8:42 PMephemient
01/14/2023, 8:42 PMChris Lee
01/14/2023, 8:42 PMKaj Koivunen
01/14/2023, 8:43 PMChris Lee
01/14/2023, 8:43 PMephemient
01/14/2023, 8:44 PMcom.example.kotlin
package, then it's OK to simply have src/main/kotlin/Foo.kt
, src/main/kotlin/subpackage/Bar.kt
, etc. for com.example.kotlin.Foo
, com.example.kotlin.subpackage.Bar
classes, etc.ephemient
01/14/2023, 8:44 PMephemient
01/14/2023, 8:44 PMAdam S
01/14/2023, 8:48 PMsrc/main/resources
https://stackoverflow.com/q/44896538/4161471ephemient
01/14/2023, 8:50 PMephemient
01/14/2023, 8:50 PMAdam S
01/14/2023, 8:51 PMephemient
01/14/2023, 8:55 PMkotlin-stdlib.jar
and any other dependencies you may haveAdam S
01/14/2023, 8:57 PMChris Lee
01/14/2023, 8:57 PMephemient
01/14/2023, 8:57 PMjava -classpath foo.jar:bar.jar
, doing a getResource("/txt")
will look for txt
in both JARsephemient
01/14/2023, 9:00 PMephemient
01/14/2023, 9:02 PMKlitos Kyriacou
01/16/2023, 10:21 AMephemient
01/16/2023, 11:00 AM