Step-by-Step Instructions for Integrating DJ Native Swing into NetBeans RCP
Here's how to integrate DJ Native Swing into a NetBeans RCP application. We will create multiple operating-system specific modules, each with the JARs and supporting classes needed for the relevant operating system.

Then, in a module installer, we will enable only the module that is relevant for the operating system in question. I.e., if the user is on Windows, only the Windows module will be enabled, while all other modules will be disabled.
Many thanks to Aljoscha Rittner for all of the code and each of the steps below. Any errors are my own, his instructions are perfect.
1. Download DJ Native Swing.
2. Go to download.eclipse.org/eclipse/downloads/drops/R-3.6-201006080911/. There, under the heading "SWT Binary and Source", download and extract the os-specific ZIPs that you want to support.
3. Unzip your downloaded ZIPs. Rename your swt.jar in the unzipped files to the full name of the zip. For example, instead of multiple "swt.jar" files, you'll now have JAR names such as "swt-3.6-gtk-linux-x86_64.jar" and "swt-3.6-win32-win32-x86_64.jar". Because these JARs will be in the same cluster folder in the NetBeans Platform application, they will need to have different names.
4. Let's start with Linux. Put the two DJ Native Swing JARs ("DJNativeSwing.jar" and "DJNativeSwing-SWT.jar") into a NetBeans library wrapper module named "com.myapp.nativeswing.linux64". Also put the "swt-3.6-gtk-linux-x86_64.jar" into the library wrapper module, while checking the "project.xml" and making sure there's a classpath extension entry for each of the three JARs in your library wrapper module.
5. Do the same for all the operating systems you're supporting, i.e., create a new library wrapper module like the above, with the operating-system specific SWT Jar, together with the two DJ Native Swing JARs.
6. Create a new module named "DJNativeSwingAPI", with code name base "com.myapp.nativeswing.api".
7. In the above main package, create a subpackage "browser", where you'll create an API to access the different implementations:
public interface Browser {
public JComponent getBrowserComponent();
public void browseTo (URL url);
public void dispose();
}public interface BrowserProvider {
public Browser createBrowser();
}
8. Make the "browser" package public and let all the operating-system specific library wrapper modules depend on the API module.
9. In each of the operating-system specific modules, create an "impl" subpackage with the following content, here specifically for Windows 64 bit:
package com.myapp.nativeswing.windows64.impl;
import chrriis.dj.nativeswing.swtimpl.NativeInterface;
import com.myapp.nativeswing.api.browser.Browser;
import com.myapp.nativeswing.api.browser.BrowserProvider;
import org.openide.util.lookup.ServiceProvider;
@ServiceProvider(service = BrowserProvider.class)
public class Win64BrowserProvider implements BrowserProvider {
private boolean isInitialized;
@Override
public Browser createBrowser() {
initialize();
return new Win64Browser();
}
private synchronized void initialize() {
if (!isInitialized) {
NativeInterface.open();
isInitialized = true;
}
}
}
import chrriis.dj.nativeswing.NSComponentOptions;
import chrriis.dj.nativeswing.swtimpl.components.JWebBrowser;
import com.myapp.nativeswing.api.browser.Browser;
import java.net.URL;
import javax.swing.JComponent;
class Win64Browser implements Browser {
private JWebBrowser webBrowser;
public Win64Browser() {
//If not this, browser component creates exceptions when you move it around,
//this flag is for the native peers to recreate in the new place:
webBrowser = new JWebBrowser(NSComponentOptions.destroyOnFinalization());
}
public JComponent getBrowserComponent() {
return webBrowser;
}
public void browseTo(URL url) {
webBrowser.navigate(url.toString());
}
public void dispose() {
webBrowser.disposeNativePeer();
webBrowser = null;
}
}
10. Copy the above two classes into all your other operating-system specific library wrapper modules. Rename the classes accordingly.
11. In the DJ Native Swing API module, create a new subpackage named "utils", with this class, which programmatically enables/disables modules using the NetBeans AutoUpdate API:
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.netbeans.api.autoupdate.OperationContainer;
import org.netbeans.api.autoupdate.OperationContainer.OperationInfo;
import org.netbeans.api.autoupdate.OperationException;
import org.netbeans.api.autoupdate.OperationSupport;
import org.netbeans.api.autoupdate.OperationSupport.Restarter;
import org.netbeans.api.autoupdate.UpdateElement;
import org.netbeans.api.autoupdate.UpdateManager;
import org.netbeans.api.autoupdate.UpdateUnit;
import org.openide.LifecycleManager;
import org.openide.modules.ModuleInfo;
import org.openide.util.Exceptions;
import org.openide.util.Lookup;
/**
* Der ModuleHandler ist eine Hilfsklasse zum programatischen (de)aktivieren
* von Modulen und der Analyse von installierten aktiven Modulen.
* @author rittner
*/
public class ModuleHandler {
private boolean restart = false;
private OperationContainer<OperationSupport> oc;
private Restarter restarter;
private final boolean directMode;
public ModuleHandler() {
this (false);
}
public ModuleHandler(boolean directMode) {
this.directMode = directMode;
}
/**
* Gibt eine sortierte Liste der Codename-Base aller aktiven installierten
* Module zurück.
* <p>
* Es handelt sich dabei explizit um einen aktuellen Zwischenstand, der sich
* jeder Zeit verändern kann.
* @param startFilter Es werden nur die Module zurückgegeben, die mit dem Startfilter-Namen anfangen (oder null für alle)
* @param includeDisabled Wenn true, werden auch alle inaktiven Module ermittelt.
* @return Sortierte Liste der Codename-Base
*/
public List<String> getModules(String startFilter, boolean includeDisabled) {
List<String> activatedModules = new ArrayList<String>();
Collection<? extends ModuleInfo> lookupAll = Lookup.getDefault().lookupAll(ModuleInfo.class);
for (ModuleInfo moduleInfo : lookupAll) {
if (includeDisabled || moduleInfo.isEnabled()) {
if (startFilter == null || moduleInfo.getCodeNameBase().startsWith(startFilter)) {
activatedModules.add(moduleInfo.getCodeNameBase());
}
}
}
Collections.sort(activatedModules);
return activatedModules;
}
/**
* Führt einen Neustart der Anwendung durch, wenn der vorherige setModulesState
* ein Flag dafür gesetzt hat. mit force, kann der Restart erzwungen werden.
* <p>
* Man sollte nicht davon ausgehen, dass nach dem Aufruf der Methode
* zurückgekehrt wird.
* @param force
*/
public void doRestart(boolean force) {
if (force || restart) {
if (oc != null && restarter != null) {
try {
oc.getSupport().doRestart(restarter, null);
} catch (OperationException ex) {
Exceptions.printStackTrace(ex);
}
} else {
LifecycleManager.getDefault().markForRestart();
LifecycleManager.getDefault().exit();
}
}
}
/**
* Aktiviert oder deaktivert die Liste der Module
* @param enable
* @param codeNames
* @return true, wenn ein Neustart zwingend erforderlich ist
*/
public boolean setModulesState (boolean enable, Set<String> codeNames) {
boolean restartFlag;
if (enable) {
restartFlag = setModulesEnabled(codeNames);
} else {
restartFlag = setModulesDisabled(codeNames);
}
return restart = restart || restartFlag;
}
private boolean setModulesDisabled(Set<String> codeNames) {
Collection<UpdateElement> toDisable = new HashSet<UpdateElement>();
List<UpdateUnit> allUpdateUnits =
UpdateManager.getDefault().getUpdateUnits(UpdateManager.TYPE.MODULE);
for (UpdateUnit unit : allUpdateUnits) {
if (unit.getInstalled() != null) {
UpdateElement el = unit.getInstalled();
if (el.isEnabled()) {
if (codeNames.contains(el.getCodeName())) {
toDisable.add(el);
}
}
}
}
if (!toDisable.isEmpty()) {
oc = directMode ? OperationContainer.createForDirectDisable() : OperationContainer.createForDisable();
for (UpdateElement module : toDisable) {
if (oc.canBeAdded(module.getUpdateUnit(), module)) {
OperationInfo operationInfo = oc.add(module);
if (operationInfo == null) {
continue;
}
// get all module depending on this module
Set<UpdateElement> requiredElements =
operationInfo.getRequiredElements();
// add all of them between modules for disable
oc.add(requiredElements);
}
}
try {
// get operation support for complete the disable operation
OperationSupport support = oc.getSupport();
// If support is null, no element can be disabled.
if ( support != null ) {
restarter = support.doOperation(null);
}
} catch (OperationException ex) {
Exceptions.printStackTrace(ex);
}
}
return restarter != null;
}
private boolean setModulesEnabled(Set<String> codeNames) {
Collection<UpdateElement> toEnable = new HashSet<UpdateElement>();
List<UpdateUnit> allUpdateUnits =
UpdateManager.getDefault().getUpdateUnits(UpdateManager.TYPE.MODULE);
for (UpdateUnit unit : allUpdateUnits) {
if (unit.getInstalled() != null) {
UpdateElement el = unit.getInstalled();
if (!el.isEnabled()) {
if (codeNames.contains(el.getCodeName())) {
toEnable.add(el);
}
}
}
}
if (!toEnable.isEmpty()) {
oc = OperationContainer.createForEnable();
for (UpdateElement module : toEnable) {
if (oc.canBeAdded(module.getUpdateUnit(), module)) {
OperationInfo operationInfo = oc.add(module);
if (operationInfo == null) {
continue;
}
// get all module depending on this module
Set<UpdateElement> requiredElements =
operationInfo.getRequiredElements();
// add all of them between modules for disable
oc.add(requiredElements);
}
}
try {
// get operation support for complete the enable operation
OperationSupport support = oc.getSupport();
if (support != null) {
restarter = support.doOperation(null);
}
return true;
} catch (OperationException ex) {
Exceptions.printStackTrace(ex);
}
}
return false;
}
}
12. Create a ModuleInstall class in the API module. In this class, we need to create a map, connecting all the operating systems to the related code name base of the module relevant to the specific operating system. For this, we use "os.arch" and "os.name". Then we create an enable list and a disable list for the code name base. We create two handlers, one to disable everything, the other to enable just the relevant module.public class Installer extends ModuleInstall {
@Override
public void restored() {
Map modelMap = new HashMap();
modelMap.put("Windows.64", "com.myapp.nativeswing.windows64");
modelMap.put("Linux.64", "com.myapp.nativeswing.linux64");
String osArch = System.getProperty("os.arch");
if ("amd64".equals(osArch)) {
osArch = "64";
} else {
osArch = "32";
}
String osName = System.getProperty("os.name");
if (osName.startsWith("Windows")) {
osName = "Windows";
}
if (osName.startsWith("Mac")) {
osName = "Mac";
}
Map osNameMap = new HashMap();
osNameMap.put("Windows", "Windows");
osNameMap.put("Linux", "Linux");
osNameMap.put("Mac", "Mac");
String toEnable = modelMap.get(osNameMap.get(osName) + "." + osArch);
Set toDisable = new HashSet(modelMap.values());
if (toEnable != null) {
toDisable.remove(toEnable);
}
ModuleHandler disabler = new ModuleHandler(true);
disabler.setModulesState(false, toDisable);
ModuleHandler enabler = new ModuleHandler(true);
enabler.setModulesState(true, Collections.singleton(toEnable));
}
}
13. Finally, create yet another module, where the TopComponent will be found that will host the browser from DJ Native Swing. So, create a new module, add a window where the browser will appear, and set a dependency on the DJ Native Swing API module.In the constructor of the window add the following:
setLayout(new BorderLayout());
BrowserProvider bp = Lookup.getDefault().lookup(BrowserProvider.class);
if (bp!=null){
Browser createBrowser = bp.createBrowser();
add(createBrowser.getBrowserComponent(), BorderLayout.CENTER);
}
14. By default, library wrapper modules are set to "1.4" source code level and to "autoload". You will need to change "1.4" to "1.6" (since you're using annotations above). You will also need to change "autoload" to "regular", otherwise they will never be loaded, since no module depends on them.15. On Linux, at least on Ubuntu, make sure you have done something like this:
export MOZILLA_FIVE_HOME=/usr/lib/mozilla
export LD_LIBRARY_PATH=$MOZILLA_FIVE_HOME
On Linux (at least on Ubuntu), you also need to set an impl dependency on the "JNA" module.
16. In "platform.properties", add this line:
run.args.extra=-J-Dsun.awt.disableMixing=true
Hurray, you're done, once you run the application:

Note: above I followed these instructions to remove the tab in the browser window.





Comments
Edvin Syse replied on Thu, 2010/10/21 - 4:12pm
Christopher Deckers replied on Fri, 2010/10/22 - 7:53am
Hi Geertjan,
Josh let me know about this tutorial, and I think it is a great contribution!
To support Mac, there is a call to add at the end of the main() method ("NativeInterface.runEventPump()") in addition to the "-XstartOnFirstThread" VM parameter. Do you have any ideas if the main method can be accessed somehow to add this final blocking call?
Cheers,
-Christopher
Aljoscha Rittner replied on Tue, 2010/10/26 - 1:53pm
Hi!
We working on a solution, please be patient :-)
br, josh.
Vidhyadharan De... replied on Tue, 2010/11/02 - 4:10pm
Superb!
Usually i use Eclipse for this browser , Because to show i am working instead of chating :)
Hopefully i can using this now in Netbeans .. :)
I Have one small question, Is it possible to click browser hyperlink programaticaly.
Thanks,
vidhya
Patrick Gonzales replied on Mon, 2010/11/15 - 5:29pm
Christopher Deckers replied on Tue, 2010/11/16 - 4:39am
in response to:
Patrick Gonzales
Patrick,
A lot was done in DJ Native Swing itself to simplify NetBeans integration and to support Mac: this tutorial is outdated.
Get the latest DJ Native Swing, and follow the instructions from the "NetBeans.txt" file located in the distribution. If you have any questions, go to the sourceforge DJ Native Swing project page and use the help forum.
Hope this helps,
-Christopher
Greg Hanowski replied on Sun, 2010/11/28 - 1:09am
in response to:
Christopher Deckers
Christopher Deckers replied on Sun, 2010/11/28 - 4:38am
in response to:
Greg Hanowski
Hi Greg,
Get the latest 0.9.9 preview (not the 0.9.8) and there should be "NetBeans.txt" in the "netbeans" folder.
Hope this helps,
-Christopher
Greg Hanowski replied on Sun, 2010/11/28 - 2:37pm
in response to:
Christopher Deckers
Hi Christopher,
Thanks, got it now.
Unfortunately, it appears the instructions were meant for someone with a lot more experience in NetBeans than I. I don't think I have a prayer of following them. Althouogh I've been programming in Java using NetBeans for more than 1 year and consider myself to be fairly decent at Java (I have a major project I've developed), it is possible to be decent at Java without understanding NetBeans very well since initial setup happens only once while java programming happens every day. Although I have successfully added several 3rd party libaries to my project, nothing this complicated.
If I can ever figure out how to get it working, maybe my contribution to the project will be clear instructions to people like me (probably the majority of java programmers), expanding your user base.
Ok here we go:
1. Create main application
With dependencies: (what's that mean?)
-Auto update Service (what's that?)
-Lookup (what's that)
-Progress API (what's that?)
Change compilation level to 1.6 -> to be set for all modules (what's a module?) due to the use of certain annotations (what's an annotation?)
I would expect to find something called compilation level under the Run menu or maybe the Compiling section of of the Project Properties form. Nope. No clue how to do this.
2. In "platform.properties", add this line:
run.args.extra=-J-Dsun.awt.disableMising=true
( I see a Java Platforms and NetBeans Platforms under Tools, but nowhere do I see platform.properties)
Well I guess I'll stop here. No point going further. I think you get the idea of what level I (we) are at.
Greg
Christopher Deckers replied on Mon, 2010/11/29 - 12:23pm
in response to:
Greg Hanowski
Hi Greg,
Are you building a NetBeans RCP or creating a normal Swing application using NetBeans?
If you are creating a normal Swing application, then simply include the JARs in your classpath and follow what the demo application shows.
If you are building a NetBeans RCP, then you need dependencies to be bundled into modules, which are the steps described in the "NetBeans.txt" file. In such case, one would definitely know how to create and configure a module.
Please let me know if some of my assumptions are not correct or if you have any comments.
-Christopher
Greg Hanowski replied on Tue, 2010/11/30 - 12:26am
in response to:
Christopher Deckers
Hi Christopher,
Since I've never heard of RCP, I guess I must have a normal Swing application. In the interest of educating other readers of this thread, RCP stands for Rich-Client Platform. If you search for it in NetBeans help file, it returns nothing. I had to google it to find out. Now that's as much as I know about it.
Here's some further education for NetBeans users. If you include the .jar files from the top-level folder of the DJNativeSwing download, ie. DJNativeSwing.jar, DJNativeSwing-SWT.jar, and DJNativeSwing-SWTDemo.jar and try to implement according to included examples you will have problems:
Exception in thread "main" java.lang.IllegalStateException: This call must happen in the AWT Event Dispatch Thread! Please refer to http://java.sun.com/docs/books/tutorial/uiswing/concurrency/index.html and http://java.sun.com/javase/6/docs/api/javax/swing/SwingUtilities.html#invokeLater(java.lang.Runnable)
at chrriis.dj.nativeswing.swtimpl.core.MessagingInterface.checkUIThread(MessagingInterface.java:161)
at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface.checkUIThread(SWTNativeInterface.java:450)
at chrriis.dj.nativeswing.swtimpl.core.SWTNativeComponent.runSync(SWTNativeComponent.java:175)
at chrriis.dj.nativeswing.swtimpl.components.core.NativeWebBrowser.navigate(NativeWebBrowser.java:734)
at chrriis.dj.nativeswing.swtimpl.components.JWebBrowser.navigate(JWebBrowser.java:311)
at chrriis.dj.nativeswing.swtimpl.components.JWebBrowser.navigate(JWebBrowser.java:301)
at javaapplication14.TabWeb.initComponents(TabWeb.java:27)
at javaapplication14.TabWeb.<init>(TabWeb.java:21)
at javaapplication14.GUI.initComponents(GUI.java:1825)
at javaapplication14.GUI.<init>(GUI.java:2622)
at javaapplication14.Main.main(Main.java:10)
Java Result: 1
BUILD SUCCESSFUL (total time: 19 seconds)
Instead, add the jar files from the NetBeans folder. To add them to your project library, Right-click on your project name in the Projects tree listing on the left and select Properties. Then select Libraries from the Categories tree on the left and click the Add JAR/Folder button. Navigate to the folder where you extracted the DJNativeSwing-SWT-0-9-9-20101112-1.zip file from the download and then into the netbeans folder. Select the two jar files there, DJNativeSwing-SWPTAPI.jar and DJNativeSwing-SWTCore.jar, and click the Open button. Now you will see them in the Compile-time Libraries list. Click OK to dismiss the Project Properties form.
Oops, I guess that doesn't work either. More problems:
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/swt/SWT
at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface.initialize_(SWTNativeInterface.java:204)
at chrriis.dj.nativeswing.swtimpl.NativeInterface.initialize(NativeInterface.java:71)
at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface.open_(SWTNativeInterface.java:312)
at chrriis.dj.nativeswing.swtimpl.NativeInterface.open(NativeInterface.java:100)
at javaapplication14.GUI.initComponents(GUI.java:1824)
at javaapplication14.GUI.<init>(GUI.java:2622)
at javaapplication14.Main.main(Main.java:10)
Caused by: java.lang.ClassNotFoundException: org.eclipse.swt.SWT
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 7 more
Java Result: 1
Well anyway, thats the way I setup the Lobo project and it worked the first time. But then you have to settle for a web page that leaves out chunks and sets table background colors red. Which is why I haven't given up yet on DJNativeSwing. I'll reply again if I can figure out what I'm doing wrong.
Greg
Greg Hanowski replied on Tue, 2010/11/30 - 1:36am
I figured the problem must be something in the way I was trying to integrate it into my project so thought I'd take a step back and make a stand-alone app using Christopher's SimpleWebBrowserExample.java, located in the ...\src\DJNativeSwing-SWTDemo\chrriis\dj\nativeswing\swtimpl\demo\examples\webbrowser folder. It worked!
I used the jar files in the top-level folder, not the netbeans folder.
Now that I have confidence it actually works, maybe I can try again to figure out how to integrate it into my project.
Greg
Greg Hanowski replied on Tue, 2010/11/30 - 2:50am
in response to:
Greg Hanowski
Yeh, I finally got it integrated into my applicat!
My application consists of a main GUI that uses a JTabbedPane. Each pane is a separate class. So I created a new tab called "Web" for the new DJNativeSwing panel. I created a new class called TabWeb. I reduced Christopher's SimpleWebBrowserExample.java further so that the TabWeb class contains only this:
The main culprit in the original code causing all the errors was this line:
webBrowser.navigate("http://www.google.com");
That's easy to put in a separate method to be called later.
I don't know what this line in the original code is for:
NativeInterface.runEventPump();
It seems to work fine without out. Maybe I'll found out later :-)
I visited the same site that was causing all the problems in the Lobo project and it looked great!
Thanks for the help Christopher and great job on a super effort! Hope this thread helps out others like me.
Greg
Sandeep Rai replied on Mon, 2012/06/18 - 5:58am
Hi,
I tried integrating DJNative-Swing into my swing application bt i get following error please help.
NativeSwing[1]: Exception in thread "main" java.lang.UnsatisfiedLinkError: Cannot load 32-bit SWT libraries on 64-bit JVM NativeSwing[1]: at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source) NativeSwing[1]: at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source) NativeSwing[1]: at org.eclipse.swt.internal.C.(Unknown Source) NativeSwing[1]: at org.eclipse.swt.widgets.Display.(Unknown Source) NativeSwing[1]: at java.lang.Class.forName0(Native Method) NativeSwing[1]: at java.lang.Class.forName(Class.java:186) NativeSwing[1]: at org.eclipse.swt.graphics.Device.(Unknown Source) NativeSwing[1]: at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface$OutProcess.runNativeSide(SWTNativeInterface.java:1163) NativeSwing[1]: at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface.main_(SWTNativeInterface.java:1347) NativeSwing[1]: at chrriis.dj.nativeswing.swtimpl.NativeInterface.main(NativeInterface.java:220) NativeSwing[2]: Exception in thread "main" java.lang.UnsatisfiedLinkError: Cannot load 32-bit SWT libraries on 64-bit JVM NativeSwing[2]: at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source) NativeSwing[2]: at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source) NativeSwing[2]: at org.eclipse.swt.internal.C.(Unknown Source) NativeSwing[2]: at org.eclipse.swt.widgets.Display.(Unknown Source) NativeSwing[2]: at java.lang.Class.forName0(Native Method) NativeSwing[2]: at java.lang.Class.forName(Class.java:186) NativeSwing[2]: at org.eclipse.swt.graphics.Device.(Unknown Source) NativeSwing[2]: at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface$OutProcess.runNativeSide(SWTNativeInterface.java:1163) NativeSwing[2]: at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface.main_(SWTNativeInterface.java:1347) NativeSwing[2]: at chrriis.dj.nativeswing.swtimpl.NativeInterface.main(NativeInterface.java:220) NativeSwing[3]: Exception in thread "main" java.lang.UnsatisfiedLinkError: Cannot load 32-bit SWT libraries on 64-bit JVM NativeSwing[3]: at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source) NativeSwing[3]: at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source) NativeSwing[3]: at org.eclipse.swt.internal.C.(Unknown Source) NativeSwing[3]: at org.eclipse.swt.widgets.Display.(Unknown Source) NativeSwing[3]: at java.lang.Class.forName0(Native Method) NativeSwing[3]: at java.lang.Class.forName(Class.java:186) NativeSwing[3]: at org.eclipse.swt.graphics.Device.(Unknown Source) NativeSwing[3]: at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface$OutProcess.runNativeSide(SWTNativeInterface.java:1163) NativeSwing[3]: at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface.main_(SWTNativeInterface.java:1347) NativeSwing[3]: at chrriis.dj.nativeswing.swtimpl.NativeInterface.main(NativeInterface.java:220) Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: java.net.SocketException: Connection reset at chrriis.dj.nativeswing.swtimpl.core.OutProcessSocketsMessagingInterface.openChannel(OutProcessSocketsMessagingInterface.java:67) at chrriis.dj.nativeswing.swtimpl.core.MessagingInterface.initialize(MessagingInterface.java:57) at chrriis.dj.nativeswing.swtimpl.core.OutProcessSocketsMessagingInterface.(OutProcessSocketsMessagingInterface.java:32) at chrriis.dj.nativeswing.swtimpl.core.OutProcessSocketsMessagingInterface$SwingOutProcessSocketsMessagingInterface.(OutProcessSocketsMessagingInterface.java:162) at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface$OutProcess.createOutProcessMessagingInterface(SWTNativeInterface.java:992) at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface$OutProcess.createOutProcessCommunicationChannel(SWTNativeInterface.java:735) at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface.open_(SWTNativeInterface.java:320) at chrriis.dj.nativeswing.swtimpl.NativeInterface.open(NativeInterface.java:100) at jframes.searches.(searches.java:50) at jframes.searches$7.run(searches.java:604) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:705) at java.awt.EventQueue.access$000(EventQueue.java:101) at java.awt.EventQueue$3.run(EventQueue.java:666) at java.awt.EventQueue$3.run(EventQueue.java:664) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) at java.awt.EventQueue.dispatchEvent(EventQueue.java:675) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105) at java.awt.EventDispatchThread.run(EventDispatchThread.java:90) Caused by: java.net.SocketException: Connection reset at java.net.SocketInputStream.read(SocketInputStream.java:189) at java.net.SocketInputStream.read(SocketInputStream.java:121) at java.io.BufferedInputStream.fill(BufferedInputStream.java:235) at java.io.BufferedInputStream.read1(BufferedInputStream.java:275) at java.io.BufferedInputStream.read(BufferedInputStream.java:334) at java.io.ObjectInputStream$PeekInputStream.read(ObjectInputStream.java:2283) at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2296) at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2767) at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:798) at java.io.ObjectInputStream.(ObjectInputStream.java:298) at chrriis.dj.nativeswing.swtimpl.core.OutProcessSocketsMessagingInterface.openChannel(OutProcessSocketsMessagingInterface.java:65) ... 23 more
Matt Coleman replied on Tue, 2012/06/19 - 2:12am
the coolest feature graphic designer buffalo
Sandeep Rai replied on Tue, 2012/06/19 - 7:34am
in response to:
Greg Hanowski
Hi Greg
I tried integrating DJNative-Swing into my swing application bt i get following error please help.
NativeSwing[1]: Exception in thread "main" java.lang.UnsatisfiedLinkError: Cannot load 32-bit SWT libraries on 64-bit JVM
Could you help ?
Sandeep Rai replied on Tue, 2012/06/19 - 7:36am
in response to:
Christopher Deckers
Hi Chriss
I tried integrating DJNative-Swing into my swing application bt i get following error please help.
NativeSwing[1]: Exception in thread "main" java.lang.UnsatisfiedLinkError: Cannot load 32-bit SWT libraries on 64-bit JVM.
Christopher Deckers replied on Wed, 2012/06/20 - 4:00pm
in response to:
Sandeep Rai
The problem is because you don't have the right version of SWT for your target environment. The 32bit Windows version is part of the distribution, but you need a different "swt.jar", for 64 bit Windows, or 32/64 Linux, etc.
You can find a recent SWT version here:
http://download.eclipse.org/eclipse/downloads/drops4/S-4.2M7-201205031800/index.php#SWT
Please use the project's forum to post your questions: http://sourceforge.net/projects/djproject/forums/forum/671154
Hope this helps,
-Christopher
Sandeep Rai replied on Thu, 2012/06/28 - 4:44am
in response to:
Christopher Deckers
Thanks for the reply i'll use this :)
My java project got delayed :(
I'll revert back on the forum from now on.
Thanks Again
-Sandeep
Javier Ortiz replied on Wed, 2012/12/19 - 6:30pm
I got the loading part right, but when I try to use it, it can't find the appropriate swt classes (When ran from windows 64). I did it on a Maven project. Here's the relevant part of the respective pom for the Windows 64 module:
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>nbm-maven-plugin</artifactId> <extensions>true</extensions> <configuration> <!-- To have the jar plugin pickup the nbm generated manifest --> <useDefaultManifestFile>true</useDefaultManifestFile> <moduleType>normal</moduleType> swt.windows.64/1</codeNameBase> <publicPackages> <publicPackage>org.eclipse.swt</publicPackage> </publicPackages> </configuration> </plugin>I translates to org.eclipse.swt.*. It seems to be a Maven module issue since it already tries to load from correct module.