Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » JAR built on Windows fails to paint on Linux(JAR built on Windows fails to paint on Linux)
JAR built on Windows fails to paint on Linux [message #650854] Wed, 26 January 2011 20:54 Go to next message
Brian  is currently offline Brian Friend
Messages: 2
Registered: January 2011
Junior Member
We are in the process of enhancing our product by offering both an AWT and SWT version. We deploy both versions in one jar file that is built on Windows. Up until now we have been able to built on windows and deploy on all our supported Unix platforms. Now that we have incorporated SWT into the jar we have to build on Linux and windows. This causes issue for the deployment of our product, it would be ideal to still only build one jar to deploy everywhere.

A little background.
The class that seems to be causing the problem extends org.eclipse.swt.widgets.Canvas
It also implements some JNI interface to communicate with native C++ code.
After our constructor calls super to create the object we do some initialization on it by adding the DisposeListener and the PaintListener.
The PaintListener is where we implement a re-parenting mechanism that has to run otherwise our SWT viewer will not show up.

The problem:
When we build the jar on Windows and try to use it on Linux we never get the paint event. If we could figure out why we don't get the paint event we think our issue would be solved.
If we build the jar on Linux the paint occurs on Linux, but if we use it on windows the same thing happens and the paint does not occur.

We have noticed that the class files that are created for this specific class are different between windows and linux. however when we decompile them there is no difference.

In theory the jar should be able to be built once and run everywhere, and nothing should be different between the platforms.

Another side note is that both the windows and linux jars work on AIX which is motif, our linux is GTK.

Anyone have any ideas on what we are seeing?
icon5.gif  Re: JAR built on Windows fails to paint on Linux [message #651231 is a reply to message #650854] Fri, 28 January 2011 13:34 Go to previous message
Brian  is currently offline Brian Friend
Messages: 2
Registered: January 2011
Junior Member
Update on this issue:
Through further debugging I have found it is the use of JNI that is causing the events to not occur when we build the jar on windows and run on Linux.

From what i have read the JNI usage with SWT is platform specific and if used the jar has to be build on the platform you are trying to use.

Below is a small example of our code, from what i have read what we did with the JNI layer is bad, or at least against convention. How would we write this class to be platform independent so that we can build one jar for all platforms?

public class SWTCanvas extends Canvas

protected native void nativeResizeViewerWnd(long hViewerWnd, long hWnd);
Composite parent,
int style,
int wndType,
long hWnd)

super(parent, SWT.NONE);

private void initialize()

addControlListener(new ControlListener()
public void controlMoved(ControlEvent e) {}
public void controlResized(ControlEvent e)
nativeResizeViewerWnd(m_hNativeWnd, handle);
Previous Topic:Should ExpandBar flicker noticeably when being resized?
Next Topic:how to sort ComboBoxCellEditor in a table
Goto Forum:

Current Time: Wed Jan 27 08:35:25 GMT 2021

Powered by FUDForum. Page generated in 0.01354 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top