intellij why does `getResource` give me null? I ha...
# announcements
m
intellij why does
getResource
give me null? I have a
.txt
file in the same directory with
MyClass.java
I print the class with this code
Copy code
println(MyClass::class.java)
it returns me
class com.myapp.vendors.lib.MyClass
However when I want to get the txt file with this code:
Copy code
println(MyClass::class.java.getResource("my.txt"))
it returns me null
e
Resources must be inside the
resources
dir (or whatever dir is configured in your build file), not beside
.java
files:
Copy code
src/
  main/
    java/
      MyClass.java
  resources/
    my.txt
💯 2
Also, this is more of a general JVM/Java question. Maybe try SOstackoverflow
m
src/resources/com/myapp/vendors/lib/my.txt
to be precise 🙂
☝️ 1
e
Indeed, thanks Marc 🙂