I am using install4j to install an intranet application which requires an HTTP and HTTPS port. I would like to test that these ports are available and warn the user/block the installation until they select unavailable ports.
The only avenue I see for this (besides custom code) is to ensure the windows service fails if the application cannot bind to needed ports, and use a Failure Strategy “Ask user whether to retry or quit on failure”. In the web server startup code, I use System.exit(1) if the server cannot bind to ports. However, this does not appear to register as a failure to the installer – the installation proceeds without invoking the failure strategy.
What is the proper approach for signaling failure to the “Start a service” action? Have other people taken an alternate approach to guaranteeing the installation uses available ports?
A good alternate approach I’ve since found: add a custom code action:
Good explanation of how to wire this up here