Class InstallConfig


  • public class InstallConfig
    extends java.lang.Object
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  InstallConfig.OSType  
    • Constructor Summary

      Constructors 
      Constructor Description
      InstallConfig​(java.lang.String company, java.lang.String version, java.lang.String applicationNameShort, java.lang.String applicationNameLong)
      Creates a configuration object for the installation with all the necessary informations
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void createConfigDirs​(java.util.ArrayList<java.lang.String> directorys)
      Creates the given directory in the configuration directory
      void createPathEntry()
      [Windows] creates a entry in the path variable for the program TODO: create Launcher wie unter Linux
      void createProgramDirs​(java.util.ArrayList<java.lang.String> directorys)
      Creates the given directory in the application directory
      void createServiceUnitFile​(boolean startAtBoot, java.lang.String unitDescription, java.lang.String unitAfter, java.lang.Integer unitStartLimitBurst, java.lang.Integer unitStartLimitInterval, java.lang.String installWantedBy, java.lang.String installAliasName, java.lang.String serviceWorkingDir, java.lang.String serviceUser, java.lang.String serviceGroup, java.util.List<java.lang.String> serviceEnvironment, java.util.List<java.lang.String> serviceExecStartPre, java.util.List<java.lang.String> serviceExecStartPost, java.lang.Integer serviceTimeout, java.lang.String serviceType, java.util.List<java.lang.String> serviceExecStart, java.lang.String serviceExecStop, java.lang.String serviceRestart, java.lang.Integer serviceRestartSec)
      [Linux] Creates a unit file for systemd.
      java.lang.String getApplicationDir()
      Returns the main directory of the application.
      protected java.lang.String getApplicationNameLong()  
      protected java.lang.String getApplicationNameShort()  
      protected java.lang.String getCompany()  
      java.lang.String getConfigDir()
      Returns the configuration directory of the application: /home/user/.config/ or C:\Users\User\AppData\ If the path isn't existing, it will be created
      protected boolean getCreateDesktopEntry()  
      protected tk.rpjosh.installer.Data getData()  
      protected boolean getDebug()  
      protected java.lang.String getDesktopDir()
      Returns the path of the desktop
      protected java.lang.String getDesktopLinuxPNG()  
      protected java.lang.String getDesktopWindowsICO()  
      protected int getEstimatedSize()
      [Windows] Returns the setted estimates size of the program
      protected java.util.Map<java.lang.String,​java.lang.String> getFontsToInstall()  
      protected boolean getIsPortable()  
      protected boolean getIsUser()  
      protected java.lang.String getLocationOfJarFile()
      Returns the path to the actual jar file
      protected int getMaxHeapSize()  
      protected boolean getOffline()  
      static InstallConfig.OSType getOsType()  
      protected java.lang.String getPortableDir()
      Returns the main directory of the portable installation
      protected boolean getQuiet()  
      protected boolean getResource​(java.lang.String pathInJar, java.lang.String pathToWrite)
      Extracts a file from the jar file and copy it to the given path
      protected boolean getResource​(java.lang.String pathInJar, java.lang.String pathToWrite, boolean logError)
      Extracts a file from the jar file and copy it to the given path
      protected boolean getRunInBackgroundByDefault()  
      protected java.lang.String getVersion()  
      protected void initApplicationDir()  
      void installDesktopEntry​(java.lang.String windowsICO, java.lang.String linuxPNG, java.lang.String keywords)
      Creates a desktop entry during the installation
      void setDebug​(boolean debug)
      When the debug mode is enabled, all error messages will be printed out exactly
      void setDesktopCategories​(java.lang.String categories)
      [Linux] Sets the categories in which the applications should be present in the menus (desktop entry)
      void setDesktopKeywords​(java.lang.String keywords)
      [Linux] Sets the keywords for the application (desktop entry)
      void setDownloadOfflinePath​(java.lang.String path)
      Installs the executable from the local file systems instead of downloading the file
      void setDownloadURLForProgramm​(java.lang.String url, char[] basicAuthUser, char[] basicAuthPassword)
      Sets the URL of the file to be installed.
      void setDownloadURLForProgramm​(java.lang.String url, char[] basicAuthUser, char[] basicAuthPassword, java.lang.String end)
      Sets the URL of the file to be installed.
      void setEstimatedSize​(double estimatedSize)
      [Windows] The estimated size of the whole application which should been displayed to the user
      void setFontsToInstall​(java.util.Map<java.lang.String,​java.lang.String> fonts)
      The given fonts will be installed (the fonts has to be in the format .ttf)
      void setIconForWindowsUninstaller​(java.lang.String windowsICO)
      [Windows] Icon for the removal of the application.
      protected void setLocationOfJarFile​(java.lang.String location)
      Sets the path to the jar runtime path -> overwrite for the portable installation
      void setMaxHeapSize​(int sizeInMb)
      Sets the maximum heap size the JVM may consume (-Xmx)
      void setPortable​(java.lang.String dir)
      Installs the program portable
      void setQuiet​(boolean quiet)
      If the installation should be executed in the background -> no command prompt will appear and prompts will be ignored
      void setRunInBackgroundByDefault​(boolean runInBackground)
      When the application is launched from the command line, the program will be launched in the foreground normally.
      void setUserInstallation()
      [Windows] Installs the program only for the actual user -> administrator rights aren't necessary
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • downloadURL

        protected java.lang.String downloadURL
      • addVersion

        protected boolean addVersion
      • urlEnding

        protected java.lang.String urlEnding
      • authUsername

        protected char[] authUsername
      • authPassword

        protected char[] authPassword
      • desktopCategories

        protected java.lang.String desktopCategories
      • desktopKeywords

        protected java.lang.String desktopKeywords
      • createPathVariable

        protected boolean createPathVariable
      • createIconForDeletion

        protected boolean createIconForDeletion
      • iconForDeletionPath

        protected java.lang.String iconForDeletionPath
      • isInstallationStarted

        protected boolean isInstallationStarted
      • createUnitFile

        protected boolean createUnitFile
      • startAtBoot

        protected java.lang.Boolean startAtBoot
      • unitDescription

        protected java.lang.String unitDescription
      • unitAfter

        protected java.lang.String unitAfter
      • unitStartLimitBurst

        protected java.lang.Integer unitStartLimitBurst
      • unitStartLimitInterval

        protected java.lang.Integer unitStartLimitInterval
      • installWantedBy

        protected java.lang.String installWantedBy
      • installAliasName

        protected java.lang.String installAliasName
      • serviceWorkingDir

        protected java.lang.String serviceWorkingDir
      • serviceUser

        protected java.lang.String serviceUser
      • serviceGroup

        protected java.lang.String serviceGroup
      • serviceEnvironment

        protected java.util.List<java.lang.String> serviceEnvironment
      • serviceExecStartPre

        protected java.util.List<java.lang.String> serviceExecStartPre
      • serviceExecStartPost

        protected java.util.List<java.lang.String> serviceExecStartPost
      • serviceTimeout

        protected java.lang.Integer serviceTimeout
      • serviceType

        protected java.lang.String serviceType
      • serviceExecStart

        protected java.util.List<java.lang.String> serviceExecStart
      • serviceExecStop

        protected java.lang.String serviceExecStop
      • serviceRestart

        protected java.lang.String serviceRestart
      • serviceRestartSec

        protected java.lang.Integer serviceRestartSec
    • Constructor Detail

      • InstallConfig

        public InstallConfig​(java.lang.String company,
                             java.lang.String version,
                             java.lang.String applicationNameShort,
                             java.lang.String applicationNameLong)
        Creates a configuration object for the installation with all the necessary informations
        Parameters:
        company - the name of your company under which the application should be installed
        version - the version
        applicationNameShort - the short name of your application
        applicationNameLong - the long name of your application
    • Method Detail

      • setDebug

        public void setDebug​(boolean debug)
        When the debug mode is enabled, all error messages will be printed out exactly
        Parameters:
        debug - if the debug mode should been enabled
      • getDebug

        protected boolean getDebug()
      • setQuiet

        public void setQuiet​(boolean quiet)
        If the installation should be executed in the background -> no command prompt will appear and prompts will be ignored
        Parameters:
        quiet - Whether to run the installation in the background
      • getQuiet

        protected boolean getQuiet()
      • getVersion

        protected java.lang.String getVersion()
      • getCompany

        protected java.lang.String getCompany()
      • getApplicationNameShort

        protected java.lang.String getApplicationNameShort()
      • getApplicationNameLong

        protected java.lang.String getApplicationNameLong()
      • getData

        protected tk.rpjosh.installer.Data getData()
      • getIsUser

        protected boolean getIsUser()
      • getIsPortable

        protected boolean getIsPortable()
      • setFontsToInstall

        public void setFontsToInstall​(java.util.Map<java.lang.String,​java.lang.String> fonts)
        The given fonts will be installed (the fonts has to be in the format .ttf)
        Parameters:
        fonts - a map with all the fonts: the name without .ttf | location of the fonts within the jar file (with .ttf)
      • getFontsToInstall

        protected java.util.Map<java.lang.String,​java.lang.String> getFontsToInstall()
      • setDownloadURLForProgramm

        public void setDownloadURLForProgramm​(java.lang.String url,
                                              char[] basicAuthUser,
                                              char[] basicAuthPassword)
        Sets the URL of the file to be installed. The executable will be downloaded from the specified URL
        Parameters:
        url - the URL
        basicAuthUser - [ the user for the basic auth ]
        basicAuthPassword - [ the passwort for the basic auth ]
      • setDownloadURLForProgramm

        public void setDownloadURLForProgramm​(java.lang.String url,
                                              char[] basicAuthUser,
                                              char[] basicAuthPassword,
                                              java.lang.String end)
        Sets the URL of the file to be installed. The executable will be downloaded from the specified URL In addition the operation system and the architecture will be added automatically to the URL (_windows_x64, _linux_arm32)
        Parameters:
        url - die URL (without file extension)
        basicAuthUser - [ the user for the basic auth ]
        basicAuthPassword - [ the passwort for the basic auth ]
        end - die file ending of the file (.jar)
      • setDownloadOfflinePath

        public void setDownloadOfflinePath​(java.lang.String path)
        Installs the executable from the local file systems instead of downloading the file
        Parameters:
        path - the path of the jar file in the file system
      • getOffline

        protected boolean getOffline()
      • installDesktopEntry

        public void installDesktopEntry​(java.lang.String windowsICO,
                                        java.lang.String linuxPNG,
                                        java.lang.String keywords)
        Creates a desktop entry during the installation. - Windows: a entry will be created in the public desktop or in the user desktop directory (for a user installation). also an entry in the start menu will be created. - Linux: the desktop file will be registered into the start menu. The given picrute will be saved under the program directory under pics/desktop.png / pics/desktop.ico
        Parameters:
        windowsICO - [Windows] the path to the .ico file inside the jar file (resource/pic.ico). The optimum resolution is 256x256
        linuxPNG - [Linux] the path of the .png file inside the jar file ...
        keywords - [Linux] key-words for the desktop entry e.g: Spiele;Berichtshefte;Dokumente;Textverarbeitung;
      • getDesktopWindowsICO

        protected java.lang.String getDesktopWindowsICO()
      • getDesktopLinuxPNG

        protected java.lang.String getDesktopLinuxPNG()
      • getCreateDesktopEntry

        protected boolean getCreateDesktopEntry()
      • setDesktopCategories

        public void setDesktopCategories​(java.lang.String categories)
        [Linux] Sets the categories in which the applications should be present in the menus (desktop entry)
        Parameters:
        categories - the categories separated by a ';' (e.g. Office;AudioVideo;Network;System)
      • setDesktopKeywords

        public void setDesktopKeywords​(java.lang.String keywords)
        [Linux] Sets the keywords for the application (desktop entry)
        Parameters:
        keywords - the keywords separated by a ';'
      • setRunInBackgroundByDefault

        public void setRunInBackgroundByDefault​(boolean runInBackground)
        When the application is launched from the command line, the program will be launched in the foreground normally. With the parameter --b can the program be launched in the foreground
        Parameters:
        runInBackground - whether the program should be launched in background by default -> for launching it in the foreground the parameter --f is required
      • getRunInBackgroundByDefault

        protected boolean getRunInBackgroundByDefault()
      • createServiceUnitFile

        public void createServiceUnitFile​(boolean startAtBoot,
                                          java.lang.String unitDescription,
                                          java.lang.String unitAfter,
                                          java.lang.Integer unitStartLimitBurst,
                                          java.lang.Integer unitStartLimitInterval,
                                          java.lang.String installWantedBy,
                                          java.lang.String installAliasName,
                                          java.lang.String serviceWorkingDir,
                                          java.lang.String serviceUser,
                                          java.lang.String serviceGroup,
                                          java.util.List<java.lang.String> serviceEnvironment,
                                          java.util.List<java.lang.String> serviceExecStartPre,
                                          java.util.List<java.lang.String> serviceExecStartPost,
                                          java.lang.Integer serviceTimeout,
                                          java.lang.String serviceType,
                                          java.util.List<java.lang.String> serviceExecStart,
                                          java.lang.String serviceExecStop,
                                          java.lang.String serviceRestart,
                                          java.lang.Integer serviceRestartSec)
        [Linux] Creates a unit file for systemd. All the given parameters are optional (except startAtBoot). For the ..Exec.. parameters and the working directory you can use #~LaunchScript~#, #~AppPath~#, #~ConfigPath~# with a leading slash -> /home/myPath/
        Parameters:
        startAtBoot - whether the service should start at boot time
        unitDescription - the description of the service
        unitAfter - after which target the service should been started
        unitStartLimitBurst - the maximum number of start retries
        unitStartLimitInterval - the interval in seconds in which the maximum number of start retries should been summarized
        installWantedBy - to which time of the boot process the service should been started -> multi-user.target (normal) or graphical.target (when GUI is needed)
        installAliasName - an alias for the service name
        serviceWorkingDir - the working directory of the service
        serviceUser - the user for the service
        serviceGroup - the group for the service
        serviceEnvironment - the environment variables to set
        serviceExecStartPre - the commands to execute before the service starts. Use to replace the location of the launch script
        serviceExecStartPost - the commands to execute after the service has started. Use to replace the location of the launch script
        serviceTimeout - the number of seconds which should been allowed to start / stop the service
        serviceType - the type of the service -> oneshot, simple, exec and forking
        serviceExecStart - the start command. Please take in mind that only with the type "oneshot" multiple commands can be specified. Use to replace the location of the launch script
        serviceExecStop - the stop command. Use #LaunchScript# to replace the location of the launch script
        serviceRestart - whether the service should been restarted when the execution failed -> on-failure or always
        serviceRestartSec - the number of seconds to wait between a restart
      • setEstimatedSize

        public void setEstimatedSize​(double estimatedSize)
        [Windows] The estimated size of the whole application which should been displayed to the user
        Parameters:
        estimatedSize - the estimated size in megabyte
      • getEstimatedSize

        protected int getEstimatedSize()
        [Windows] Returns the setted estimates size of the program
        Returns:
        the estimated size in bytes
      • setIconForWindowsUninstaller

        public void setIconForWindowsUninstaller​(java.lang.String windowsICO)
        [Windows] Icon for the removal of the application. A file (pics/uninstall.ico) will be created.
        Parameters:
        windowsICO - the path of the .ico file inside of the jar file (e.g. resource/uninstall.ico)
      • setPortable

        public void setPortable​(java.lang.String dir)
        Installs the program portable
        Parameters:
        dir - the main directory for the portable installation (e.g. C:/Users/de03710/MyProgram/)
      • setUserInstallation

        public void setUserInstallation()
        [Windows] Installs the program only for the actual user -> administrator rights aren't necessary
      • createPathEntry

        public void createPathEntry()
        [Windows] creates a entry in the path variable for the program TODO: create Launcher wie unter Linux
      • getDesktopDir

        protected java.lang.String getDesktopDir()
        Returns the path of the desktop
        Returns:
        desktop path: /home/user/Desktop/ or C:/User/myUserName/Desktop/. when no path could been determined, null will be returned
      • getConfigDir

        public java.lang.String getConfigDir()
        Returns the configuration directory of the application: /home/user/.config/ or C:\Users\User\AppData\ If the path isn't existing, it will be created
        Returns:
        the path of the directory: /home/user/.config/Company/ShortName/
      • createConfigDirs

        public void createConfigDirs​(java.util.ArrayList<java.lang.String> directorys)
        Creates the given directory in the configuration directory
        Parameters:
        directorys - a list with all the directorys to create. This are relative paths -> logs/ or config/
      • getApplicationDir

        public java.lang.String getApplicationDir()
        Returns the main directory of the application. If the directory doesn't exist, it will be created
        Returns:
        the path of the application dir: C:/Program Files/Company/MyProgram/
      • createProgramDirs

        public void createProgramDirs​(java.util.ArrayList<java.lang.String> directorys)
        Creates the given directory in the application directory
        Parameters:
        directorys - a list with all the directorys to create. This are relative paths -> logs/ or config/
      • initApplicationDir

        protected void initApplicationDir()
      • getPortableDir

        protected java.lang.String getPortableDir()
        Returns the main directory of the portable installation
        Returns:
        the path: C:/Users/de03710/BeMa/
      • getResource

        protected boolean getResource​(java.lang.String pathInJar,
                                      java.lang.String pathToWrite,
                                      boolean logError)
        Extracts a file from the jar file and copy it to the given path
        Parameters:
        pathInJar - the path in the jar file to extract: resource/48x48.png
        pathToWrite - the destination path
        logError - if an error message should be displayed
        Returns:
        if the resource was sucessfully extracted
      • getResource

        protected boolean getResource​(java.lang.String pathInJar,
                                      java.lang.String pathToWrite)
        Extracts a file from the jar file and copy it to the given path
        Parameters:
        pathInJar - the path in the jar file to extract: resource/48x48.png
        pathToWrite - the destination path
        Returns:
        if the resource was sucessfully extracted
      • getLocationOfJarFile

        protected java.lang.String getLocationOfJarFile()
        Returns the path to the actual jar file
        Returns:
        the absolute path to the jar file: C:/Users/myUserName/BeMa.jar. When no jar file was found (when launched in Eclipse) the path to the "extracted" jar file will be returned
      • setLocationOfJarFile

        protected void setLocationOfJarFile​(java.lang.String location)
        Sets the path to the jar runtime path -> overwrite for the portable installation
        Parameters:
        location - the absolute path to the jar file: C:/Users/de03710/BeMa.jar
      • setMaxHeapSize

        public void setMaxHeapSize​(int sizeInMb)
        Sets the maximum heap size the JVM may consume (-Xmx)
        Parameters:
        sizeInMb - the maximum size in megabye
      • getMaxHeapSize

        protected int getMaxHeapSize()