After you ran your main class in eclipse just go to File > Export > Runnable JAR
. Select the matching configuration to your file.
You should get that :

If you need to load swt dynamically:
public static String getArchFilename(String prefix)
{
return prefix + "_" + getOSName() + "_" + getArchName() + ".jar";
}
private static String getOSName()
{
String osNameProperty = System.getProperty("os.name");
if (osNameProperty == null)
{
throw new RuntimeException("os.name property is not set");
}
else
{
osNameProperty = osNameProperty.toLowerCase();
}
if (osNameProperty.contains("win"))
{
return "win";
}
else if (osNameProperty.contains("mac"))
{
return "osx";
}
else if (osNameProperty.contains("linux") || osNameProperty.contains("nix"))
{
return "linux";
}
else
{
throw new RuntimeException("Unknown OS name: " + osNameProperty);
}
}
private static String getArchName()
{
String osArch = System.getProperty("os.arch");
if (osArch != null && osArch.contains("64"))
{
return "64";
}
else
{
return "32";
}
}
public static void addJarToClasspath(File jarFile)
{
try
{
URL url = jarFile.toURI().toURL();
URLClassLoader urlClassLoader = (URLClassLoader) ClassLoader.getSystemClassLoader();
Class<?> urlClass = URLClassLoader.class;
Method method = urlClass.getDeclaredMethod("addURL", new Class<?>[] { URL.class });
method.setAccessible(true);
method.invoke(urlClassLoader, new Object[] { url });
}
catch (Throwable t)
{
t.printStackTrace();
}
}
Then :
File swtJar = new File(getArchFilename("lib/swt"));
addJarToClasspath(swtJar);
assuming te structure outside the jar is :
lib/swt_win_32.jar
lib/swt_win_64.jar
lib/swt_linux_32.jar
lib/swt_linux_64.jar
From http://www.chrisnewland.com/select-correct-swt-jar-for-your-os-and-jvm-at-runtime-191