블로그

ej-technologies의 제품 뉴스, 업데이트 및 인사이트입니다.

RSS로 읽어보세요. 이메일로 구독하세요. 에서 팔로우하세요.

Beyond installing

2010-12-31
Emmanuel 작성
In the two last articles, I showed how to build an installer with install4j for Sweet Home 3D, then improve it with various options. But a program lives, and more and more users are used to getting program updates automatically. As install4j includes an auto-update feature, I'm going to use it to update Sweet Home 3D when a new version is released. Finally, I'll provide all the nice options that install4j offers for Mac OS X and Linux users by creating a cross platform installer.

Auto-updating

install4j offers various ways to check whether updates are available and to manage the launching of the updater. As I want to provide auto-updating without modifying the Sweet Home 3D source code at this moment, I'm going to set options in install4j that will check if a new version of the program is available when the program is launched. The auto-update feature is informed about the availability of a new version thanks to an updates.xml file I'll have to host at a specified URL. Each time an installer is built, install4j creates a default updates.xml file in the output directory, and when a new version will be available, I'll just have to upload that file along with the new version of the installer. For the version 3.0 of the installer, this file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
  <updateDescriptor baseUrl="">
  <entry targetMediaFileId="80" updatableVersionMin="" updatableVersionMax=""
    fileName="SweetHome3D-3.0-windows.exe" newVersion="3.0" newMediaFileId="80"
    fileSize="27361280" bundledJre="windows-x86-1.6.0_23" archive="false">
  <comment language="en" />
  <comment language="zh_CN" />
  <comment language="cs" />
  <comment language="fr" />
  <comment language="de" />
  <comment language="el" />
  <comment language="hu" />
  <comment language="it" />
  <comment language="ja" />
  <comment language="pl" />
  <comment language="pt_BR" />
  <comment language="ru" />
  <comment language="es" />
  <comment language="sv" />
  </entry>
  </updateDescriptor>

To prepare future updates, I have to decide in this version where I'll host the updates.xml file. Thus, I enter the URL "http://www.sweethome3d.com/download/updates.xml " in Auto-Update Options tab of the Installer screen.
블로그 그림

Then, in the Screens & Actions tab, I click on the Insert button and select the Add Application menu item.
블로그 그림

In the Select an Application Template dialog box, I select the Updater with silent version check template.
블로그 그림

Once I click on OK, a new node is added to Installer screen for the updater application and I name its Executable as "SweetHome3DUpdater " in its Properties tab.
블로그 그림

To run this updater automatically when Sweet Home 3D or Furniture Library Editor are launched, I click on the Launcher Integration tab, select the Start automatically when launcher is executed option and choose to Always run the updater.
블로그 그림

Minimum auto-updating is now integrated and I just have to build a new installer to make it available for a future version of the program.

To test it, I immediately install version 3.0 of the program, generate an installer with a fake 3.0.1 higher version number,
블로그 그림

and upload SweetHome3D-3.0.1-windows.exe and updates.xml to http://www.sweethome3d.com/download after adding a small comment in default language to updates.xml file.
<?xml version="1.0" encoding="UTF-8"?>
  <updateDescriptor baseUrl="">
  <entry targetMediaFileId="80" updatableVersionMin="" updatableVersionMax=""
    fileName="SweetHome3D-3.0.1-windows.exe" newVersion="3.0.1" newMediaFileId="80"
    fileSize="27427328" bundledJre="windows-x86-1.6.0_23" archive="false">
  <comment>Fixed minor bugs</comment/>
  </entry>
  </updateDescriptor>

Then, a few seconds after I launch Sweet Home 3D version 3.0, the updater is launched and offers to download Sweet Home 3D version 3.0.1.
블로그 그림

If I click on the Show comments link, I get the comments entered in the updates.xml file.
블로그 그림

Otherwise the download of the new version is started.
블로그 그림

Once downloaded, I choose to execute the downloaded installer.
블로그 그림

Because the installer detects that a previous version is installed on my computer, it asks me whether to update or to install it in another location before performing the installation.
블로그 그림

Managing cross platform installers

Since install4j is a Java program itself, it's easy to prepare installers for each operating system where JVMs are available. If an application shares the same list of files (which is generally the case), I would just have to create a different media for each targeted operating system with its dedicated JRE. It's a little more complicated for Sweet Home 3D since it requires different Java 3D DLLs for different platforms. Therefore, I download Java 3D zip binaries for Mac OS X, Linux 32 bits and Linux 64 bits at Java 3D release builds page. Each of these zipped files contains a j3d-jre.zip file, and each j3d-jre.zip file contains the three j3dcore.jar, vectmath.jar and j3dutils.jar files which are the same as the Windows ones I have already, plus some DLLs like libj3dcore-ogl.so under Linux that I have to keep. Under Mac OS X, Java 3D works thanks to JOGL library, that I download too.
Once I retrieve all these files, I copy the ones required by Java 3D in a lib subdirectory of Install directory and reorganize them to avoid any name conflict.
블로그 그림

These files will have to be copied in the lib subdirectory of the destination directory where program will be installed. To copy only the Java 3D files required for a given operating system, I'm going to create one file set for each system in install4j. In the Files screen, I click first on the Insert button and choose the New File Set option.
블로그 그림

I enter the general name "Windows ",
블로그 그림

and renew the New File Set operation for Mac OS X, Linux 32 bits and Linux 64 bits.
블로그 그림

Then, for each of these file sets, I create a new lib folder by clicking on the Insert button and choosing the New Folder option.
블로그 그림

Once the lib subdirectories are ready, I select the one in Windows file set, click on the Insert button and choose Add Files and Directories option.
블로그 그림

In the Add Files and Directories dialog box, I choose the Single files option,
블로그 그림

click on the Next button, and select the four Java 3D DLLs for Windows in C:Program Files (x86)Sweet Home 3D 3.0lib directory.
블로그 그림

I confirm my choice, and repeat the same operation to add the Java 3D files that depends on Mac OS X, Linux 32 bits and Linux 64 bits.
블로그 그림

To get consistent file sets, I also have to remove the Java 3D DLLs from Default file set : I select the Content of C:Program Files (x86)Sweet Home 3D 3.0lib into subdirectory lib node, click on the Edit Entry button,
블로그 그림

and in the Modify Entry in the Distribution Tree dialog box, I change the entry type to Single files and select all the files in C:Program Files (x86)Sweet Home 3D 3.0lib directory except the four DLLs.
블로그 그림

Once I chose these JAR files, I move them to the lib subdirectory of the installation directory.
블로그 그림

Finally, I click on the Installation Components tab, select the Sweet Home 3D component and include Windows, Mac OS X, Linux 32 bits and Linux 64 bits file sets.
블로그 그림

Now that file sets are ready, I'm going to use them in the Windows existing media file and in the new media files for Mac OS X and Linux. I go to the Media screen,
블로그 그림

and double-click on the Windows media file to exclude the file sets that are not needed for Windows.
블로그 그림

Then, I click on New media file icon to create Linux 32 bits media file. In the Installer type combo box, I choose Unix/Linux GUI installer,
블로그 그림

and click on the Next button until the Data files step where I enter the same download URL http://ovh.dl.sourceforge.net/project/sweethome3d/FurnitureLibraryEditor/ for the Furniture Library Editor as I did for Windows media.
블로그 그림

In the Bundled JRE step, I click on the Download JREs button,
블로그 그림

to download Linux (x86) 1.6.0_23 JRE.
블로그 그림

Once downloaded, I choose this JRE,
블로그 그림

customize the installer by setting the media file name to "${compiler:sys.shortName}-${compiler:sys.version}-linux-32bits "
블로그 그림

and by excluding the file sets of the other operating systems.
블로그 그림

Once the Media wizard is finished for Linux 32 bits, I create similarly the media file for Linux 64 bits, and rename them as Linux 32 bits and Linux 64 bits with the Rename Media File menu item available in their contextual menu, to be able to distinguish more easily.
블로그 그림

Mac OS X installer is very similar to the other installers except it doesn't need to download a JRE and it requires an additional VM option to run: as Mac OS X provides its own JRE with the Java 3D 1.3.1 library in extension directory, I have to change the java.ext.dirs system property to ensure the Java 3D 1.5.2 library installed with Sweet Home 3D will have a higher priority. To set this VM option that should replace the -Djava.library.path=lib existing one, I create the java3dDllsVMOption compiler variable by clicking on the Insert button in the Compiler Variables tab of the General Settings screen and enter "-Djava.library.path=lib " as its default value.
블로그 그림

Then in the Java invocation step of SweetHome3D launcher, I update the text of the VM Parameters field with ${compiler:java3dDllsVMOption}.
블로그 그림

Finally, I click on New media file icon, choose Mac OS X folder Installer type,
블로그 그림

update the download URL, exclude the file sets of the other operating systems and in Compiler variables step, override java3dDllsVMOption variable with the value
-Djava.ext.dirs=lib:/Library/Java/Extensions:/System/Library/Java/Extensions:
/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/ext

블로그 그림

I can now build the 4 installers and test them on each operating system.
블로그 그림


블로그 그림


블로그 그림


블로그 그림

Conclusion

install4j offers many options to help with auto-updating installed software and to deliver Java cross platform installers and uninstallers. install4j can create installers for all supported platforms on any supported platform, so on a Linux build server you can create installers for Windows and Mac OS X as well.
아카이브