Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How to build Windows 7/64-bit SWT apps
How to build Windows 7/64-bit SWT apps [message #768790] Tue, 20 December 2011 19:58 Go to next message
Bill  is currently offline Bill Friend
Messages: 13
Registered: February 2011
Junior Member
We would like to build SWT/JFace apps that run on my 64-bit Windows 7 PC.

When we run the jar file, we get this message:
Cannot load 32-bit SWT libraries on 64-bit JVM

How do we fix this?
Re: How to build Windows 7/64-bit SWT apps [message #769056 is a reply to message #768790] Wed, 21 December 2011 10:14 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Bill,<br>
<br>
Did you download the 64 bit version of Eclipse?  I.e., <font
size="+1"><span class="filename">eclipse-SDK-3.7.1-win32-x86_<b>64</b>.zip</span>
</font><br>
<br>
<br>
On 20/12/2011 8:58 PM, Bill wrote:
<blockquote cite="mid:jcqpcd$kr1$1@news.eclipse.org" type="cite">We
would like to build SWT/JFace apps that run on my 64-bit Windows 7
PC.
<br>
<br>
When we run the jar file, we get this message:
<br>
 Cannot load 32-bit SWT libraries on 64-bit JVM
<br>
<br>
How do we fix this?
<br>
<br>
</blockquote>
</body>
</html>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to build Windows 7/64-bit SWT apps [message #769107 is a reply to message #769056] Wed, 21 December 2011 12:25 Go to previous messageGo to next message
Francois Missing name is currently offline Francois Missing nameFriend
Messages: 15
Registered: October 2011
Junior Member
Yes, for a reason I've never understood, 32 bits SWT versions are not running on a 64 bits JVM (which by the way is really annoying). So either you download a 32 bits Java version either you download the 64 bits SWT version.

François
Re: How to build Windows 7/64-bit SWT apps [message #769300 is a reply to message #769107] Wed, 21 December 2011 18:55 Go to previous messageGo to next message
Bill  is currently offline Bill Friend
Messages: 13
Registered: February 2011
Junior Member
Thanks everyone who has tried to help. Below I will explain the many failed attempts to fix this and ask again for any help.

For anyone else having this problem, the following links may be helpful:

http://www.eclipse.org/swt/eclipse.php
http://stackoverflow.com/questions/2921193/swt-on-windows-64-bit

Situation:
1. Trying to create stand alone SWT/JFace app.
2. Totally don't care if it's 32, 64 or 179.3 bits.
3. In Windows/Preferences/Java/Installed JREs, have tried selecting both 32 bit and 64 bit JRE's. Have downloaded and installed others.
4. Out of desperation, may go and install a different version of Eclipse (and probably break countless other projects).
5. We always get the message:
java.lang.UnsatisfiedLinkError: Cannot load 64-bit SWT libraries on 32-bit JVM


I've heard a few things now, so maybe these questions will shed light:

1. When launching an app from Eclipse, simply editing the settings in "Window/Prefs/Java/Installed JREs" should allow us to launch an app with either a 32-bit JRE or a 64-bit JRE regardless of what version of Eclipse I am running. True?

2. Some say you need to have both the 32-bit and 64-bit versions of the jar file. What's with that? Given that SWT is a wrapper around native controls, why would anyone want to complicate things further? I can't believe this.
Re: How to build Windows 7/64-bit SWT apps [message #774071 is a reply to message #769300] Tue, 03 January 2012 08:01 Go to previous messageGo to next message
Christoph Keimel is currently offline Christoph KeimelFriend
Messages: 482
Registered: December 2010
Location: Germany
Senior Member
I am building 32-bit applications on 64-bit win7. I had a similar problem, when I started the project. My solution was as follows:

1) I use the 32-bit version of eclipse (indigo)
2) I have the 32-bit JDK (1.6.0_29) registered und marked under "Installed JREs"
3) Be sure to have the 32-bit JDK selected as "Runtime JRE" in the run configuration

I also have a JAVA_HOME system variable pointing to the 32-bit JDK, but I think this has nothing to do with the SWT issue.

Hope this helps ...
Re: How to build Windows 7/64-bit SWT apps [message #774106 is a reply to message #774071] Tue, 03 January 2012 09:21 Go to previous messageGo to next message
Francois Missing name is currently offline Francois Missing nameFriend
Messages: 15
Registered: October 2011
Junior Member
Christoph Keimel wrote on Tue, 03 January 2012 03:01
I am building 32-bit applications on 64-bit win7. I had a similar problem, when I started the project. My solution was as follows:

1) I use the 32-bit version of eclipse (indigo)
2) I have the 32-bit JDK (1.6.0_29) registered und marked under "Installed JREs"
3) Be sure to have the 32-bit JDK selected as "Runtime JRE" in the run configuration

I also have a JAVA_HOME system variable pointing to the 32-bit JDK, but I think this has nothing to do with the SWT issue.

Hope this helps ...


Yes but with this solution, if you deploy your app on another 64 bits workstation having only the 64 bits JRE(or even both version but with the 64bits version as the default) you will get the message "Cannot load 32-bit SWT libraries on 64-bit JVM".

François
Re: How to build Windows 7/64-bit SWT apps [message #774318 is a reply to message #769300] Tue, 03 January 2012 17:27 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
The bitness of the jvm and of the swt being used must match because the
jvm will refuse to load swt's native libraries otherwise. SWT verifies
this the first time that a library load is requested so that if this is
not satisfied then a meaningful error message is output (the one you're
seeing) rather than the more generic java.lang.UnsatisfiedLinkError that
occurs otherwise.

So if you want to have a single download that can be run with either a
32- or 64-bit jvm then you need to ship both 32- and 64-bit swt jars,
and determine at runtime which of them to load. Java's "os.arch" system
property can be used to determine this, as its value reflects the
bitness of the jvm, not of the OS (so it will answer something like
"i386" or "i686" when using a 32-bit jre on a 64-bit OS, which is what
you're interested in).

Grant


On 12/21/2011 1:55 PM, Bill wrote:
> Thanks everyone who has tried to help. Below I will explain the many
> failed attempts to fix this and ask again for any help.
>
> For anyone else having this problem, the following links may be helpful:
>
> http://www.eclipse.org/swt/eclipse.php
> http://stackoverflow.com/questions/2921193/swt-on-windows-64-bit
>
> Situation:
> 1. Trying to create stand alone SWT/JFace app.
> 2. Totally don't care if it's 32, 64 or 179.3 bits.
> 3. In Windows/Preferences/Java/Installed JREs, have tried selecting both
> 32 bit and 64 bit JRE's. Have downloaded and installed others.
> 4. Out of desperation, may go and install a different version of Eclipse
> (and probably break countless other projects).
> 5. We always get the message:
> java.lang.UnsatisfiedLinkError: Cannot load 64-bit SWT libraries on
> 32-bit JVM
>
>
> I've heard a few things now, so maybe these questions will shed light:
>
> 1. When launching an app from Eclipse, simply editing the settings in
> "Window/Prefs/Java/Installed JREs" should allow us to launch an app with
> either a 32-bit JRE or a 64-bit JRE regardless of what version of
> Eclipse I am running. True?
>
> 2. Some say you need to have both the 32-bit and 64-bit versions of the
> jar file. What's with that? Given that SWT is a wrapper around native
> controls, why would anyone want to complicate things further? I can't
> believe this.
>
Re: How to build Windows 7/64-bit SWT apps [message #777038 is a reply to message #768790] Mon, 09 January 2012 17:50 Go to previous messageGo to next message
H. M. is currently offline H. M.Friend
Messages: 4
Registered: January 2012
Junior Member
hi,

I get this error message trying to run the swtexample.jar described in
"Running standalone SWT Examples outside of Eclipse" on Win7 64bit using JRE 7.0U2 (64bit):

Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons:
no swt-gtk-3659 in java.library.path
no swt-gtk in java.library.path
Can't load library: C:\Windows\TEMP\swtlib-64\swt-gtk-3659.dll
Can't load library: C:\Windows\TEMP\swtlib-64\swt-gtk.dll

at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source)
at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source)
at org.eclipse.swt.internal.C.<clinit>(Unknown Source)
at org.eclipse.swt.internal.Converter.wcsToMbcs(Unknown Source)
at org.eclipse.swt.internal.Converter.wcsToMbcs(Unknown Source)
at org.eclipse.swt.widgets.Display.<clinit>(Unknown Source)
at org.eclipse.swt.examples.controlexample.ControlExample.main(ControlEx
ample.java:215)

Compiling my own SWT-Apps work within Eclipse with the following settings:
Eclipse 3.7.1 (64bit)
Java SDK (64 bit)
SWT-3.7.1 (64 bit)

I get the same error above after deploying, when it correctly compile with eclipse.

Using JRE7_U2_64bit instead after uninstalling SDK, I also get the same error above, but already within Eclipse.

I am sure there is something wrong with my (sys) configuration.

BTW in Ubuntu 11.10 it works with the Linux SWT64 bit and SDK7_U2

Any suggestions?

Thx.
Regards
Hagen




Re: How to build Windows 7/64-bit SWT apps [message #777458 is a reply to message #777038] Tue, 10 January 2012 14:50 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
SWT does not support running GTK on Windows, you need to be pointing at
the swt jar for win32.

Grant


On 1/9/2012 12:50 PM, H. M. wrote:
> no swt-gtk-3659 in java.library.path
Re: How to build Windows 7/64-bit SWT apps [message #777492 is a reply to message #777458] Tue, 10 January 2012 15:45 Go to previous messageGo to next message
H. M. is currently offline H. M.Friend
Messages: 4
Registered: January 2012
Junior Member
I tried it already, but no effect and I did not use the Linux SWT.
I already uninstalled all java versions and reinstalled them but no chance.

On another Win7 Pc with JRE7_U2 running it works all fine.

It might be the fact that the swt.dll files cannot be copied temporarily to the \..\AppData\Local\Temp directory (like it is on another machine). Every attemp to run the example or another SWT app it creates an empty swtlib-64 folder. I also made a test with another new created user account, but the error still occurs... It must be something with the system configuration, but I cannot locate the error at the moment.

[Updated on: Tue, 10 January 2012 15:45]

Report message to a moderator

Re: How to build Windows 7/64-bit SWT apps [message #780767 is a reply to message #777492] Thu, 19 January 2012 10:30 Go to previous messageGo to next message
H. M. is currently offline H. M.Friend
Messages: 4
Registered: January 2012
Junior Member
Problem solved!
I had to reinstall win7, Confused now it works!
Re: How to build Windows 7/64-bit SWT apps [message #780964 is a reply to message #777492] Thu, 19 January 2012 10:30 Go to previous messageGo to next message
H. M. is currently offline H. M.Friend
Messages: 4
Registered: January 2012
Junior Member
Problem solved!
I had to reinstall win7, :? now it works!
Re: How to build Windows 7/64-bit SWT apps [message #885695 is a reply to message #768790] Wed, 13 June 2012 12:55 Go to previous message
Tom Silverman is currently offline Tom SilvermanFriend
Messages: 1
Registered: June 2012
Junior Member
I was teaching 'Eclipse Plugins' the other day to a class of developers who were all working on Windows 7 64 bit OS's. Some installed the course provided Helios RCP 32 bits IDE and some were working with their usual Indigo JavaEE IDE 64 bits.

We were exercising stand alone SWT applications. The only solution that actually worked for those who were using the Helios 32 bits to avoid the 'Could not load SWT library' problem was to install a 32 bits JDK. They had to reconfigure the IDE installed JRE (through the IDE preferences) to actually point to the 32 bits JDK. We did not try the -d32 JVM argument yet on a 64 bits version JVM.

BTW: The %JAVA_HOME% environment variable is, in my opinion, totally irrelevant in newer versions of Windows in this context. It seems Windows obtains the information from the registry and not from the environment variable and when you issue the 'java -version' command in a console you will always get the version that was installed with Windows installer regardless of the JAVA_HOME environment variable.

[Updated on: Wed, 13 June 2012 13:00]

Report message to a moderator

Previous Topic:Combo dropdown issue on 3.7.2
Next Topic:How to control visibility of buttons in property sheet
Goto Forum:
  


Current Time: Thu Mar 28 10:44:51 GMT 2024

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

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

Back to the top