brentking
Posts: 2
Joined: Tue Mar 19, 2019 12:26 pm

Downloading JRE and Resources

Hi there,

This concerns using the Java version of Advanced Installer to bundle a jre and resources such they are downloaded by the installer (rather than contained within it) during installation.

I have no problem using Advanced Installer to bundle Open JDK 11 into the installer (for use only by our appliication) though this makes the installer larger than we would like. I wanted to check, is it possible to get the installer to download Open JDK 11 from our server to the application's directory and configure it to run the application?

From what I can see, downloading a version of Java as a pre-requisite involves getting the ORACLE (i.e. not free) version and installing it globally, neither od which we want to do.


Similarly, we have a set of voice files that our application uses, which need to simply be copied to a location that the application is aware of. I create a configuration directory for the application in the user's home directory and copy the voices to it. In the past, I've simply bundled the voices into the installer and used it to create the configuration directory and copy the voices to it, but this doubles the size of the installer.

Is it possible to get the installer to download the voice files from our server and put them in the configuration directory? From what I can see, AI's pre-requisites feature seems to be more to do with downloading and running a set-up program, rahther than downloading a resource to a defined location.

Thanks for any advice you can give.

Brent
Catalin
Posts: 6607
Joined: Wed Jun 13, 2018 7:49 am

Re: Downloading JRE and Resources

Hello Brent and welcome to Advanced Installer forums,

There are two approaches to your problem here, both of them including a custom action.

The first approach, which is easier, would be to use our predefined "Open URL". In this custom action, you can pass as parameters the direct download link for your files, whether it is the Open JDK 11 or the audio files.

Cons of this approach:

1- the output folder can not be configured. The files will be downloaded in the default location that is set on the target machine
2- additional steps required in order to achieve your first task (to also install the Open JDK 11).

The second approach would be to create a script (e.g. PowerShell) which will do both of the above steps. For instance, we can use the WebClient class which provides common methods for sending data to and receiving data from a resource identified by a URI. The method that we need to use here is the WebClient.DownloadFile() method, which takes as input the following:

- the URI address
- the output folder which also must contain the filename

For example, here is a little PowerShell script which downloads Notepad++ in a predefined folder that I have created on my Desktop:

Code: Select all

url = "https://notepad-plus-plus.org/repository/7.x/7.6.4/npp.7.6.4.Installer.exe"
$outputFolder = "C:\Users\Catalin\Desktop\MyFolder\npp.7.6.4.Installer.exe"

$webClient = New-object System.Net.WebClient
$webClient.DownloadFile($url,$outputFolder)
For instance, if you want Notepad++ to be downloaded before your main package is launched, you can proceed as it follows:

- open your project and go to "Custom Actions" page.

- here add a "PowerShellScriptInline" custom action with sequence. In order to add a custom action with sequence, all you have to do is to press the "Add custom action with sequence" button which is placed to the right side of the custom action's name.

- now copy and paste the content of the above script under the "Your code goes here" comment.

- you can schedule the custom action to only execute during Install by unchecking the "Uninstall" and "Maintenance" options from under the "Dialogs Stage Condition" section.

- depending on the time you want the custom action to be executed, you can schedule it accordingly by simply dragging and dropping it in the installation sequence. Since our example was to download the Notepad++ before the main setup is launched, please schedule the custom action before "Searches" action group - "Wizard Dialogs Stage"

Quick note: Up until now, these are the steps that are required to fulfill your second request (just to download some audio files to a specific location)

Now, in order to fulfill your first request (also install the file after the download process is complete), we can add some more functionality to our script. For instance, if after the download, we want to silently install the Notepad++, we can proceed as it follows:

Modify the script to also install Notepad++:

Code: Select all

$url = "https://notepad-plus-plus.org/repository/7.x/7.6.4/npp.7.6.4.Installer.exe"
$outputFolder = "C:\Users\Catalin\Desktop\MyFolder\npp.7.6.4.Installer.exe"

$webClient = New-object System.Net.WebClient
$webClient.DownloadFile($url,$outputFolder)

Start-Process -Wait -FilePath $outputFolder -ArgumentList "/S"
The steps on how to implement this within your Advanced Installer project are the same as those described above.

Hope this helps.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
brentking
Posts: 2
Joined: Tue Mar 19, 2019 12:26 pm

Re: Downloading JRE and Resources

Hi Caitlin,

Many thanks for the detailed information. I'll look into this and do some experiments ASAP.

For the voice files, method 2 sounds like it is the best option, as they only need to be put somewhere where the application jar file knows where to find them. As for the jre, I can probably get away with just bundling it into the installer as Java 11 allows me to remove any non-essential jre components.

I'll experiment with the method you suggested. Thank you again for your help.

regards,

Brent
Catalin
Posts: 6607
Joined: Wed Jun 13, 2018 7:49 am

Re: Downloading JRE and Resources

You are always welcome, Brent.

Glad to help.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”