tags:

views:

235

answers:

3

I've recently started learning SWT (on class #4, to be precise) due to business requirements, and previously I had been developing with Swing for 2 years.

We deployed Swing applications as jars with resource dependencies. In SWT, what are the deployable forms and equivalents?

I have questions but since my training is online, I'm on a course-ware and there is no instructor, except StackOverflow:

  1. Can SWT apps be deployed as independent EXE's? And what's with the "Eclipse EXE" thing people talk about? Does it mean that all SWT outputs will be Eclipse based EXEs? Or can they be completely independent EXEs?

  2. If the answer to 1 is yes, how does the compiler produce native win32 executable code? This is one area where I'm thoroughly confused. Typically, a deployable jar is fed to the VM which reads the manifest and does its stuff, but an EXE as output? What's really behind the scenes?

  3. How are external resource bundles managed? At the time of deployment?

  4. Internationalization support?

Thanks.

+1  A: 

Deploying an SWT application is exactly like deploying a Swing app, with the addition of several jars and a native library. You must currently be using some tool to make exe files for your Swing app; that tool may or may not be competent to also package up a native code library. It is unlikely that the tool is creating 'native win32 executable code'. Rather, it is packaging up Java class files along with the JRE and a stub Windows PE file.

SWT is developed as part of Eclipse. Eclipse has the Rich Client Platform, or RCP. If you build your Java application as an RCP application, you can use the Eclipse tools to generate an executable package for Windows (or anywhere else). It is not a single executable, it's a directory with an executable in it. However, you don't have to use Eclipse to use SWT.

An RCP application has to use much more than just SWT. It has to be constructed as a set of OSGi bundles that depend on the core Eclipse platform. Once you have such a thing running inside Eclipse, there is a wizard in Eclipse that will create a Windows 'executable' (a directory containing your code in JAR file(s), a lot of Eclipse code in JAR files, the JRE, and a PE .exe stub). You can automate that process from ant, though I've never done it myself. You will need to do book-length reading to get up to speed on all of this, I fear.

There no difference between SWT and Swing in terms of resources and internationalization. Other Eclipse-related libraries include an I18N discipline, but not the core SWT. You just use locales and property files as in any other Java application.

bmargulies
Thanks for the clear response. Just wondering: In eclipse, how do I generate an executable package for Windows? Say I have a the traditional HelloSWT shell coded up. Can you specify the steps to getting an executable package (if only it's not too long to list, otherwise I'll hunt it down when I have time).
SWT Beginner
I'll edit my answer.
bmargulies
A: 

basically you need get ur project running with conventional java -jar command

then create an exe bootstrap program that run the command when you double click it

extra things can be done like checking JVM versions inside the exe program

Dapeng
+1  A: 

Hi there

SWT is not Eclipse-based, but the Eclipse UI is SWT-based. Eclipse uses the SWT library for its drawing. It is used a GUI library from the Eclipse consortium, available for many systems. If you want to deploy your normal Java Application with an SWT GUI you just add the corresponding libs and .dll's or .so's. Therefore, everything you can do (deployment) with Java respectively speaking Swing, can be done with SWT, if you provide the according libraries. There are tools and ways to compile everything into .exe's but that is not necessarily needed. I do not really get the Eclipse EXE thing you are talking about, but eclipse just provides a starter exe, which is basically just a wrapper. Otherwise, some people refer to Eclipse RCP als Eclipse EXE but this is not correct. You CAN use the Eclipse RCP to base your App and this would use SWT as UI library. But you can use SWT all by yourself just as library without the Eclipse trail.

I hope this helps.