Stefan Oltmann
10/13/2021, 11:53 AMFile(".").absolutePath
returns the working directory which I could change in a symlink.
Server.class.getProtectionDomain().getCodeSource().getLocation().getPath()
results in NullPointer if started from the EXE.
Is there something compose specific to find that out?Tomasz Krakowiak
10/13/2021, 3:08 PMStefan Oltmann
10/13/2021, 3:10 PMval path = Thread.currentThread().contextClassLoader.getResource("icon.ico")
val jarPath = path.path.substring(6, path.path.length - 10)
val pathToDir = File(jarPath)
.parentFile
.parentFile
.canonicalPath
.replace("%20", " ")
Not nice, but seems to work.ephemient
10/13/2021, 5:41 PMFile((path.openConnection() as JarURLConnection).jarFileURL.toURI())
java.io.File(this::class.java.protectionDomain.codeSource.location.toURI())
Stefan Oltmann
10/13/2021, 5:43 PMephemient
10/13/2021, 5:44 PMStefan Oltmann
10/13/2021, 5:44 PMval url = Thread.currentThread().contextClassLoader.getResource("icon.ico")
val jarPath = url.path.substring(0, url.path.length - 10)
val pathToExe = Paths.get(URI(jarPath))
.resolve("../../MyApp.exe")
.toFile()
.canonicalPath
ephemient
10/14/2021, 10:41 PMFile(.toURI())
to be far more reliable than .replace("%20", " ")
Stefan Oltmann
10/15/2021, 8:34 AMval url = Thread.currentThread().contextClassLoader.getResource("icon.ico")
val jarPath = url.path.substring(0, url.path.length - 10)
val pathToExe = Paths.get(URI(jarPath))
.resolve("../../MyApp.exe")
.toFile()
.canonicalPath
<http://Log.info|Log.info>("App location: $pathToExe")