PolyhedralDev / BiomeTool

MIT License
10 stars 0 forks source link

Failure to run when PWD is not the same as the jar's parent directory #3

Closed astrsh closed 3 years ago

astrsh commented 3 years ago

Running java -jar some-parent-directory/BiomeTool.jar will throw the below exception, cd-ing into some-parent-directory and running java -jar BiomeTool.jar works as expected.

java.io.UncheckedIOException: java.nio.file.NoSuchFileException: ./addons/bootstrap
    at com.dfsek.terra.addon.BootstrapAddonLoader.loadAddons(BootstrapAddonLoader.java:94)
    at com.dfsek.terra.AbstractPlatform.load(AbstractPlatform.java:190)
    at com.dfsek.terra.biometool.PlatformImpl.<init>(PlatformImpl.kt:23)
    at com.dfsek.terra.biometool.BiomeToolView.<init>(BiomeToolView.kt:28)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
    at java.base/java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:128)
    at java.base/jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:347)
    at java.base/java.lang.Class.newInstance(Class.java:645)
    at tornadofx.FXKt.find(FX.kt:434)
    at tornadofx.FXKt.find$default(FX.kt:423)
    at tornadofx.App.start(App.kt:83)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:847)
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:484)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
    at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
    at com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:290)
    at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.nio.file.NoSuchFileException: ./addons/bootstrap
    at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
    at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
    at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
    at java.base/sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55)
    at java.base/sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:149)
    at java.base/sun.nio.fs.LinuxFileSystemProvider.readAttributes(LinuxFileSystemProvider.java:99)
    at java.base/java.nio.file.Files.readAttributes(Files.java:1851)
    at java.base/java.nio.file.FileTreeWalker.getAttributes(FileTreeWalker.java:226)
    at java.base/java.nio.file.FileTreeWalker.visit(FileTreeWalker.java:277)
    at java.base/java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:323)
    at java.base/java.nio.file.FileTreeIterator.<init>(FileTreeIterator.java:71)
    at java.base/java.nio.file.Files.walk(Files.java:3918)
    at com.dfsek.terra.addon.BootstrapAddonLoader.loadAddons(BootstrapAddonLoader.java:87)
    ... 22 more
astrsh commented 3 years ago

Actually it's probably better this way rather than using the jars directory for the config & addon directories.