Reputation: 103
How do you set the librarypath and the native path for a jar file? I have been using jarsplice/jarmatey but I don't want to anymore. I have tried
System.setProperty("java.library.path", gameFolder+"/lib/jars" + File.separator);
System.setProperty("org.lwjgl.librarypath", gameFolder+"/lib/natives" + File.separator);
Where gamefolder if the games directory where the jar site and also
System.setProperty("java.library.path", "/lib/jars" + File.separator);
System.setProperty("org.lwjgl.librarypath", "/lib/natives" + File.separator);
and the two without file separator either and those don't work. I have also tried, since when my game gets ran by the launcher it executes the cmd line to run it, adding in the -D... to th cmd arguments like this:
String cmd = "java -jar "+gameFolder+"/progame.jar -Djava.library.path=/lib/jars -Dorg.lwjgl.librarypath=/lib/natives";
Runtime.getRuntime().exec(cmd);
and same with
String cmd = "java -jar "+gameFolder+"/progame.jar -Djava.library.path="+gameFolder+"/lib/jars -Dorg.lwjgl.librarypath="+gameFolder+"/lib/natives";
Runtime.getRuntime().exec(cmd);
And none of those work. Any help? The files are in the path and i have checked to see if the paths exists through the code and they do and whatever but I am sol in my eyes.
Upvotes: 0
Views: 2968
Reputation: 71
this is how I load the .jar outside of my environment
public static void load()
{
String fileNatives = OperatingSystem.getOSforLWJGLNatives();
System.setProperty("org.lwjgl.librarypath", System.getProperty("user.dir") + File.separator + "native" + File.separator + fileNatives);
}
and for checking what operating system the user is on
class OperatingSystem {
private static String system = System.getProperty("os.name").toLowerCase();
public static String getOSforLWJGLNatives()
{
if(system.startsWith("win"))
{
return "windows";
}
if(system.startsWith("mac"))
{
return "macosx";
}
if(system.startsWith("lin"))
{
return "linux";
}
if(system.startsWith("sol"))
{
return "solaris";
}
return "unknown";
}
}
Upvotes: 1
Reputation: 511
did you check if your gameFolder path contains a space caracter ? if so you should surround it with a double quote like
String cmd = "java -jar " +" \"" +gameFolder+"/progame.jar" +"\"" +" -Djava.library.path="+"\"" +gameFolder+"/lib/jars" +"\"" + " -Dorg.lwjgl.librarypath="+"\"" +gameFolder+"/lib/natives"+"\"";
Upvotes: 0