Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've just run into the same problem. I haven't tried it yet, but I plan to include versions of <code>swt.jar</code> for all platforms and load the correct one dynamically in the start of the <code>main</code> method.</p> <p>UPDATE: It worked. <code>build.xml</code> includes all jars:</p> <pre><code>&lt;zipfileset dir="/home/aromanov/workspace/foo/lib" includes="swt_linux_gtk_x86.jar"/&gt; &lt;zipfileset dir="/home/aromanov/workspace/foo/lib" includes="swt_macosx_x86.jar"/&gt; &lt;zipfileset dir="/home/aromanov/workspace/foo/lib" includes="swt_win32_x86.jar"/&gt; &lt;zipfileset dir="/home/aromanov/workspace/foo/lib" includes="swt_linux_gtk_x64.jar"/&gt; &lt;zipfileset dir="/home/aromanov/workspace/foo/lib" includes="swt_macosx_x64.jar"/&gt; &lt;zipfileset dir="/home/aromanov/workspace/foo/lib" includes="swt_win32_x64.jar"/&gt; </code></pre> <p>and my <code>main</code> method starts with calling this:</p> <pre><code>private void loadSwtJar() { String osName = System.getProperty("os.name").toLowerCase(); String osArch = System.getProperty("os.arch").toLowerCase(); String swtFileNameOsPart = osName.contains("win") ? "win32" : osName.contains("mac") ? "macosx" : osName.contains("linux") || osName.contains("nix") ? "linux_gtk" : ""; // throw new RuntimeException("Unknown OS name: "+osName) String swtFileNameArchPart = osArch.contains("64") ? "x64" : "x86"; String swtFileName = "swt_"+swtFileNameOsPart+"_"+swtFileNameArchPart+".jar"; try { URLClassLoader classLoader = (URLClassLoader) getClass().getClassLoader(); Method addUrlMethod = URLClassLoader.class.getDeclaredMethod("addURL", URL.class); addUrlMethod.setAccessible(true); URL swtFileUrl = new URL("rsrc:"+swtFileName); // I am using Jar-in-Jar class loader which understands this URL; adjust accordingly if you don't addUrlMethod.invoke(classLoader, swtFileUrl); } catch(Exception e) { throw new RuntimeException("Unable to add the SWT jar to the class path: "+swtFileName, e); } } </code></pre> <p>[EDIT] For those looking for the "jar-in-jar classloader": It's included in Eclipse's JDT (the Java IDE built on Eclipse). Open <code>org.eclipse.jdt.ui_*version_number*.jar</code> with an archiver and you will find a file <code>jar-in-jar-loader.zip</code> inside.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload