I made this a long time ago, and I still use it in everything I make:
package passage.games.util;
import java.io.File;
public class NativesUtil {
public static String OSNAME;
public static String NATIVES_PATH;
public static void setNativesPathToOS(){
OSNAME = System.getProperty("os.name").toLowerCase();
if(OSNAME.contains("win"))NATIVES_PATH = "project-assets/natives/windows/";
else if(OSNAME.contains("mac"))NATIVES_PATH = "project-assets/natives/macosx";
else if(OSNAME.contains("lin"))NATIVES_PATH = "project-assets/natives/linux";
else if(OSNAME.contains("sol"))NATIVES_PATH = "project-assets/natives/solaris";
else System.out.println("Sorry, your operating system is not supported.");
System.setProperty("org.lwjgl.librarypath", new File(NATIVES_PATH).getAbsolutePath());
}
}