Note that there are some explanatory texts on larger screens.

plurals
  1. POjar-in-jar class loading issue
    primarykey
    data
    text
    <p>i followed the steps described at <a href="https://stackoverflow.com/questions/2706222/create-cross-platform-java-swt-application">Create cross platform Java SWT Application</a> . i create a jar which has a swt_browser.jar containing only my class using swt library. then i added other platrom-specific swt jars. i use the below code to load the swt_browser.jar and the platform specific swt library jar. but somehow the call for loading class SWTBrowser complains :</p> <pre><code>java.lang.ClassNotFoundException: org.eclipse.swt.widgets.Layout </code></pre> <p>can you tell what i am doing wrong?</p> <p>-----code for loading swt jars-------</p> <pre><code> ClassLoader parent = Main.class.getClassLoader(); URL.setURLStreamHandlerFactory(new RsrcURLStreamHandlerFactory(parent)); URL swtBrowserFileUrl = new URL("rsrc:swt_browser.jar"); URL swtFileUrl = new URL("rsrc:" + swtFileName); ClassLoader cl = new URLClassLoader(new URL[]{swtBrowserFileUrl, swtFileUrl}, parent); Method addUrlMethod = URLClassLoader.class.getDeclaredMethod("addURL", URL.class); addUrlMethod.setAccessible(true); addUrlMethod.invoke(cl, swtBrowserFileUrl); addUrlMethod.invoke(cl, swtFileUrl); Thread.currentThread().setContextClassLoader(cl); try { // Check we can now load the SWT class -this check passes! Class.forName("org.eclipse.swt.widgets.Layout", true, cl); } catch (ClassNotFoundException exx) { System.err.println("Launch failed: Failed to load SWT class from jar: " + swtFileName); throw new RuntimeException(exx); } //this line below throws exception : java.lang.ClassNotFoundException: org.eclipse.swt.widgets.Layout Class&lt;?&gt; c = Class.forName("com.sun.star.google.gui.SWTBrowser", true, cl); Object obj = c.newInstance(); Method run = c.getMethod("run", url.getClass()); //$NON-NLS-1$ run.invoke(obj, new Object[]{url}); </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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