Samples of Custom Java Commands

JExpress includes several custom examples and templates. You're welcome to use these examples as is or modify them to meet your needs. DeNova retains the copyright on all examples.

There is a Samples subdirectory in your JExpress directory which contains both .java and .class files. These classes are designed to show how to create a custom class and access some of the API's calls. While we try to keep the classes up-to-date, you may need to adapt the source to handle changes in environments, etc. Once the class does what you want, simply add the classname to the Custom options in JExpress Advanced.

If you modify any of the examples, then add the full path to the JExpressInstaller subdirectory to your compiler's classpath. You do not want to add the installation directory for JExpress itself as you do not have a license to distribute any of the classes outside the JExpressInstaller subdirectory tree.

Please be sure to review the Java source code for important notes about each class. Some of the classes require that you modify the code to meet your needs. Also, the source tells you where you should include the class file in the Custom panel.

Here's a quick overview of the examples provided with JExpress.

Classname Description Java source
Ant build.xml Examples of Ant's build file. build.xml
build-custom.xml
SetLastModifiedDate A panel that configures the installer to retain the original time stamps on files. Simply include this class in the "After Welcome" field and define the location of the classes as Samples. .java
StartBillboards A panel that starts series of billboards, or marquees, to display in place of the installer's icon. The billboards can start at anytime during the installation, but this example starts them as soon as the user enters the installation directory.

You simply need to define a series of text files for the billboards and a background image. See the source code for details.

.java
RegisterPanel A panel that lets users input the name, company, e-mail address, and serial number. It formats the panel so it looks like the standard wizard panels in a JExpress installer. A text file, called regform.txt, is saved in the installation directory with the results.

You should only use this class After selecting the install dir or later because it needs the name of the installation directory. If you use it at any other time during the installation, then nothing will happen.

.java
InstallJBoss A panel that installs jboss. You need to adapt this class to fit the specific version of jboss which you are installing. Instructions are at the top of the file

.java
SendFeedback You can prompt your user to send feedback before they uninstall your application. Follow the instructions in the README for details about how to do this. README
WizardPanelTemplate A template for displaying text in the install wizard, changing the name of the Next button, and waiting for the user to click a button on the wizard. You must adapt this class for it to do anything. .java
CommandTemplate This panel is only the framework that shows you how to create a separate thread. You only need to create a separate thread if your class will take time to execute. If you are writing a simple panel that interacts with the user, then you probably don't need to use this method. .java
DecisionTree A panel that shows you how to change which panels are active and inactive during the installation.

You'll also need to look at the sample classes: Branch1, Branch2, and Branch3 to fully understand how fully you can control your installer with a few simple commands.

.java
MakeInstallerSilent If you'd like users to have a silent install, but you don't want to require them to pass any commands on the command line, then you can adapt this class. You'll need to specify what directory to install the app and any other data that your custom classes may need. .java
AuthenticateUpdatePanel A panel that lets users input a user id and password so the Updater can access the web server. The data entered is saved in the update.control file.

You should only use this class in After the install because it needs the name of the installation directory. If you use it at any other time during the installation, then nothing will happen.

.java
StartAppAfterUpdate A panel that lets you configure an update-on-demand so it launches the app after the update finishes.

You must change this class so it references the main classname for the program that you want to start.

.java
SkipUpdate Skip the rest of the update after the files are compared. .java
RedirectUpdater Change the URL where updates are downloaded before the Updater starts. .java
UninstallMenu Creates a menu item to uninstall your product if target machine is Windows or unix computer with gnome or kde. Of course, the user can also uninstall your product from the Add/Remove option in the Control Panel if running on Windows or the uninstall script if running on Unix or Mac.

You should only use this class in After the install because it needs the regular uninstaller created before it can add this special menu item.

.java
WinFreeDiskSpace Reports the amount of free disk space on a Windows drive. Must be adapted to meet your needs. .java
WinRegistry An example that shows how to modify the registry. Must be adapted to meet your needs. An alternative is to use the sample WinImportRegFile class or the methods in the WindowsOS class.. .java
WinImportRegFile An example that shows how to import a .reg file into the registry. Must create an install.reg file and the target machine must have Regedit.exe or Regedit32.exe in the Windows or WinNT directory. An alternative way to manage the Windows registry is with the sample WinRegistry class or the methods in the WindowsOS class. .java
InstallService If you'd your launchers installed as a service, then you can simply use the Advanced interface, click the "install as service" and "start at login". On Linux, the user will have to have root access. We include an example of how you can do this with a custom class, too. .java
MoveFiles Move all DLL files from the installation directory to the Windows\System directory. Can be easily adapted to move other files, as needed. .java
MoveTomCat Move the "tomcat" subdirectory from the installation directory to the C:\tomcat directory on Windows. Can be easily adapted to move other directories, as needed. .java
DeleteMenuItemsPanel Deletes specific menu items. Useful if you only want certain menus created depending on the user's install type. Must be adapted to meet your needs. .java
RunThirdPartyProgram By creating a class that calls RunThirdPartyProgram, you can run a third party program during the installation. Be sure to include the third party program, the RunThirdPartyProgram.class, and your custom class files in the JExpressInstaller subdirectory. .java
MoveToPanel These 2 panels demonstrate how to easily move between panels. To move to a panel out of the standard sequence during an installation, you must name the panel. You use the showPanel() method, passing the destination panel's name, to move to it.

If you add the MoveTo1Panel classname to After readme and the MoveTo2Panel classname to After install, you'll be able to see how easy it is to vary the panels that show up during an installation.

1.java
2.java
VersionPanel Creates a text file, called version.txt, in the installation directory with the product's name, version, and copyright. You could use this text file when you're displaying your About box so you only change the version number of the product in the installer. This example requires no user input.

You should only use this class in After the install because it needs the name of the installation directory. If you use it at any other time during the installation, then nothing will happen.

.java
StartApplet This class contains a main() which launches a web browser and passes a URL on the command line. Read the notes in the StartApplet.java file to see how you can use this class with the GetBrowser sample class to create a menu item or launch script to start your applet. .java
ChangePermissions Change the file permissions on a Unix system. If you build and install your installer on the same OS, then you can use Save file permissions option. You must use the Advanced interface for JExpress and click on the Advanced File Options button on the Files | Select panel to use this setting. Using the "Save file permissions options can be very slow. .java

The most up-to-date examples are on our web site.

You can use the step-by-step instructions to design your custom commands. If you have any questions about customization, please email Technical Support at support