SWT Web Installer

What is it?

The SWT web installer is a Java library that helps to install Java applications based on SWT.
It downloads from the internet the right version of the SWT GUI library for the PC where you are installing the application that uses it.

SWT is a GUI library that is based on native code, so there is a version of it for each platform (Windows, MacOSX, Linux, 32 or 64 bits...).
If you made an application based on SWT that is supposed to be installed on any platform you need therefore to either:
  1. make one setup file for each platform (they can be many).
  2. make one setup file for the most common platforms (Windows, MacOSX, Linux 32 bits?).
  3. use the SWT web installer.
Using the SWT web installer you only need one setup file.

How does it work?

When called, the SWT web installer does the following steps:.Since the SWT web installer cannot work without internet, and it can happen that the internet can be accessed only through a firewall or a proxy, the system checks with the user if there is a proxy and, in this case, if the proxy needs authorization; then it uses this information to connect to the internet.

Principles.

How do I use it for my application?


The library can be called from everywhere (it has also a main method), but the most reasonable ways to call it are:
The main class of the library is WebDownloader.
To use the library, create an instance of WebDownloader and call its download method.
The flexibility comes from the WebDownloader's constructor, which allows to specify how it is supposed to acquire the information it needs to work. These are its parameters:

The download method, which downloads list file and SWT library, has the following parameters:
Each interface used for the WebDownloader constructor parameters has a default implementation using the console, which means that all the needed data is acquired directly from the user through the console. There is a wrapper of WebDownloader, called ConsoleWebDownloader, which uses all these default implementations. The constructor of this class does not have parameters, so it is very simple to use.

The list file format

The list file is an XML file that contains:
An example of this file can be found in the osdepinstaller setup, it is called swt_list.xml.

More in details the file has this content:

<installer>
    <sites>
        <site dir="[absolute link of the site directory where the files are located]" description="[site description]"/>
        ...
    </sites>
    <configurations>
        <configuration os_type="[regular expression matching the java environment variable os.type for this platform]" os_arch="[regular expression matching the java environment variable os.arch for this platform]" description="[Human readable description of the platform]" link="[file name of the zip file in the site directory]"/>
        ...
    </configurations>
</installer>

How do I test it?

The SWT web installer comes with two batch files, one for Windows (installer.bat) and one for Unix-like environment (installer.sh), which call directly the ConsoleWebDownloader and can therefore be used to test the library on different platforms.

Why it is called osdepinstaller.jar ?

The SWT web installer can be used to download any library that is platform dependent, not only SWT.
Therefore its name is actually Operating system dependent library installer (osdepinstaller).

License

Since it is a library, the SWT web installer is covered by the LGPL v3 license.