Search code examples
javabatch-filejvmlwjgl

Java - Run a jar with VM arguments without commandline


I currently have a jar that needs the -Djava.library.path to be set for LWJGL on launch or it will throw an UnsatisfiedLinkError. To negate this problem, I have launched the jar through CMD with that VM argument using a batch file (Windows).

My question is - is there any way to do this natively in the jar without requiring some kind of launcher?


Solution

  • You can set the properties inside your program. Use either

    System.setProperty("org.lwjgl.librarypath", "path/to/natives");
    

    or

    Configuration.LIBRARY_PATH.set("path/to/natives");
    

    at the start of your main method.