how do I get access to the "main" class in a fun m...
# getting-started
b
how do I get access to the "main" class in a fun main() ? I need to access something like: MySpec::class.java.getResource("/html/file.html").readText()
s
the name of the file should do
like if you have your
main()
defined in a file called
Application.kt
, try referencing
ApplicationKt
or, well, that might actually only work from Java
from within
main
, just
this::class
might work
b
this is not defined in this context
I just made an empty class with the same package and am using that
s
whoops, never mind then lol
r
You should also be able to use
Copy code
object{}.javaClass.getResource(...)
Note: Those are curly braces after object, not parenthesis
k
If you just want any semi-related class
::main::class
works too, it's a class defined in the same package called
TestKt$main$x$1
.
💯 3
b
great, thx