Class RunTime


  • public class RunTime
    extends Object
    INTERNAL USE --- NOT official API
    not as is in version 2

    Intended to concentrate all, that is needed at startup of sikulix or sikulixapi and may be at runtime by SikuliX or any caller

    • Field Detail

      • appDataMsg

        public static String appDataMsg
      • testing

        public static boolean testing
      • testingWinApp

        public static boolean testingWinApp
      • jreVersion

        public String jreVersion
      • fTempPath

        public static File fTempPath
      • fBaseTempPath

        public File fBaseTempPath
      • fpBaseTempPath

        public String fpBaseTempPath
      • fLibsFolder

        public File fLibsFolder
      • fpJarLibs

        public String fpJarLibs
      • fpSysLibs

        public String fpSysLibs
      • fAppPath

        public File fAppPath
      • fSikulixAppPath

        public File fSikulixAppPath
      • fSikulixExtensions

        public File fSikulixExtensions
      • standardExtensions

        public String[] standardExtensions
      • fSikulixLib

        public File fSikulixLib
      • fSikulixStore

        public File fSikulixStore
      • fSikulixDownloadsGeneric

        public File fSikulixDownloadsGeneric
      • fSikulixDownloadsBuild

        public File fSikulixDownloadsBuild
      • fSikulixSetup

        public File fSikulixSetup
      • fSxBase

        public File fSxBase
      • fSxBaseJar

        public File fSxBaseJar
      • fSxProject

        public File fSxProject
      • fSxProjectTestScriptsJS

        public File fSxProjectTestScriptsJS
      • fSxProjectTestScripts

        public File fSxProjectTestScripts
      • fpContent

        public String fpContent
      • runningJar

        public boolean runningJar
      • runningInProject

        public boolean runningInProject
      • runningWindows

        public boolean runningWindows
      • runningMac

        public boolean runningMac
      • runningLinux

        public boolean runningLinux
      • javaShow

        public String javaShow
      • javaArch

        public int javaArch
      • osArch

        public String osArch
      • javaVersion

        public int javaVersion
      • javahome

        public File javahome
      • osName

        public String osName
      • sysName

        public String sysName
      • osVersion

        public String osVersion
      • linuxDistro

        public String linuxDistro
      • SXVersion

        public String SXVersion
      • SXVersionLong

        public String SXVersionLong
      • SXVersionShort

        public String SXVersionShort
      • SXSystemVersion

        public String SXSystemVersion
      • SXJavaVersion

        public String SXJavaVersion
      • ServerList

        public String[] ServerList
      • libOpenCV

        public static final String libOpenCV
      • fLibsProvided

        public File fLibsProvided
      • fLibsLocal

        public File fLibsLocal
      • useLibsProvided

        public boolean useLibsProvided
      • isJythonReady

        public boolean isJythonReady
      • isRunningIDE

        public static boolean isRunningIDE
    • Method Detail

      • isIDE

        public static boolean isIDE()
      • shouldRunServer

        public static boolean shouldRunServer()
      • getServerOptions

        public static String[] getServerOptions()
      • getServerGroups

        public static String getServerGroups()
      • getServerExtra

        public static String getServerExtra()
      • startAPI

        public static void startAPI​(String appPath)
      • shouldRunPythonServer

        public static boolean shouldRunPythonServer()
      • startAPI

        public static void startAPI()
      • asFolder

        public static File asFolder​(String option)
      • asFile

        public static File asFile​(String option)
      • evalArgs

        public static void evalArgs​(String[] args)
      • setAllowMultiple

        public static void setAllowMultiple()
      • isAllowMultiple

        public static boolean isAllowMultiple()
      • resolveRelativeFiles

        public static String[] resolveRelativeFiles​(String[] givenScripts)
      • resolveRelativeFile

        public static String resolveRelativeFile​(String scriptName,
                                                 String baseDir)
        a relative path is checked for existence in the current base folder, working folder and user home folder in this sequence.
        Parameters:
        scriptName -
        Returns:
        absolute file or null if not found
      • getSXArgs

        public static String[] getSXArgs()
      • setUserArgs

        public static void setUserArgs​(String[] args)
      • getUserArgs

        public static String[] getUserArgs()
      • printArgs

        public static void printArgs()
      • getElapsedStart

        public static long getElapsedStart()
      • getLogFile

        public static String getLogFile()
      • getUserLogFile

        public static String getUserLogFile()
      • getLoadScripts

        public static String[] getLoadScripts()
      • getRunScripts

        public static String[] getRunScripts()
      • runningScripts

        public static boolean runningScripts()
      • isVerbose

        public static boolean isVerbose()
      • setVerbose

        public static void setVerbose()
      • isQuiet

        public static boolean isQuiet()
      • setQuiet

        public static void setQuiet()
      • startLog

        public static void startLog​(int level,
                                    String msg,
                                    Object... args)
      • arrayToQuotedString

        public static String arrayToQuotedString​(String[] args)
      • runningIDE

        public boolean runningIDE()
      • getLastScriptRunReturnCode

        public int getLastScriptRunReturnCode()
      • setLastScriptRunReturnCode

        public void setLastScriptRunReturnCode​(int lastScriptRunReturnCode)
      • get

        public static RunTime get()
      • isTesting

        public boolean isTesting()
      • getMonitor

        public Rectangle getMonitor​(int n)
      • terminate

        public static void terminate()
      • terminate

        public static void terminate​(int retval,
                                     String message,
                                     Object... args)
      • cleanUp

        public static void cleanUp()
      • options

        public Options options()
      • shouldExport

        public boolean shouldExport()
      • loadLibrary

        public static boolean loadLibrary​(String libname)
        INTERNAL USE: load a native library from the libs folder
        Parameters:
        libname - name of library without prefix/suffix/ending
      • loadLibrary

        public static boolean loadLibrary​(String libname,
                                          boolean useLibsProvided)
        INTERNAL USE: load a native library from the libs folder
        Parameters:
        libname - name of library without prefix/suffix/ending
      • hideIDE

        public void hideIDE()
      • showIDE

        public void showIDE()
      • exportLib

        public void exportLib()
      • crash

        public void crash()
      • pause

        public static void pause​(int time)
      • pause

        public static void pause​(float time)
      • isRunningFromJar

        public boolean isRunningFromJar()
        INTERNAL USE: to check whether we are running in compiled classes context
        Returns:
        true if the code source location is a folder ending with classes (Maven convention)
      • isJava9

        public boolean isJava9​(String... args)
      • needsRobotFake

        public boolean needsRobotFake()
      • show

        public void show()
        print out some basic information about the current runtime environment
      • testSwitch

        public boolean testSwitch()
      • getVersionShort

        public String getVersionShort()
      • getSystemInfo

        public String getSystemInfo()
      • isVersionRelease

        public boolean isVersionRelease()
      • getVersion

        public String getVersion()
      • getStatus

        public void getStatus()
      • extractResourcesToFolder

        public List<String> extractResourcesToFolder​(String fpRessources,
                                                     File fFolder,
                                                     FilenameFilter filter)
        export all resource files from the given subtree on classpath to the given folder retaining the subtree
        to export a specific file from classpath use extractResourceToFile or extractResourceToString
        Parameters:
        fpRessources - path of the subtree relative to root
        fFolder - folder where to export (if null, only list - no export)
        filter - implementation of interface FilenameFilter or null for no filtering
        Returns:
        the filtered list of files (compact sikulixcontent format)
      • extractResourcesToFolderFromJar

        public List<String> extractResourcesToFolderFromJar​(String aJar,
                                                            String fpRessources,
                                                            File fFolder,
                                                            FilenameFilter filter)
        export all resource files from the given subtree in given jar to the given folder retaining the subtree
        Parameters:
        aJar - absolute path to an existing jar or a string identifying the jar on classpath (no leading /)
        fpRessources - path of the subtree or file relative to root
        fFolder - folder where to export (if null, only list - no export)
        filter - implementation of interface FilenameFilter or null for no filtering
        Returns:
        the filtered list of files (compact sikulixcontent format)
      • extractResourceToFile

        public boolean extractResourceToFile​(String inPrefix,
                                             String inFile,
                                             File outDir)
        store a resource found on classpath to a file in the given folder with same filename
        Parameters:
        inPrefix - a subtree found in classpath
        inFile - the filename combined with the prefix on classpath
        outDir - a folder where to export
        Returns:
        success
      • extractResourceToFile

        public boolean extractResourceToFile​(String inPrefix,
                                             String inFile,
                                             File outDir,
                                             String outFile)
        store a resource found on classpath to a file in the given folder
        Parameters:
        inPrefix - a subtree found in classpath
        inFile - the filename combined with the prefix on classpath
        outDir - a folder where to export
        outFile - the filename for export
        Returns:
        success
      • extractResourceToString

        public String extractResourceToString​(String inPrefix,
                                              String inFile,
                                              String encoding)
        store the content of a resource found on classpath in the returned string
        Parameters:
        inPrefix - a subtree from root found in classpath (leading /)
        inFile - the filename combined with the prefix on classpath
        encoding -
        Returns:
        file content
      • resourceLocation

        public URL resourceLocation​(String folderOrFile)
      • resourceListAsFile

        public String[] resourceListAsFile​(String folder,
                                           File target,
                                           FilenameFilter filter)
        write the list as it is produced by calling extractResourcesToFolder to the given file with system line separator
        non-compact format: every file with full path
        Parameters:
        folder - path of the subtree relative to root with leading /
        target - the file to write the list (if null, only list - no file)
        filter - implementation of interface FilenameFilter or null for no filtering
        Returns:
        success
      • resourceListAsSikulixContent

        public String[] resourceListAsSikulixContent​(String folder,
                                                     File targetFolder,
                                                     FilenameFilter filter)
        write the list as it is produced by calling extractResourcesToFolder to the given file with system line separator
        compact sikulixcontent format
        Parameters:
        folder - path of the subtree relative to root with leading /
        targetFolder - the folder where to store the file sikulixcontent (if null, only list - no export)
        filter - implementation of interface FilenameFilter or null for no filtering
        Returns:
        success
      • resourceListAsSikulixContentFromJar

        public String[] resourceListAsSikulixContentFromJar​(String aJar,
                                                            String folder,
                                                            File targetFolder,
                                                            FilenameFilter filter)
        write the list as it is produced by calling extractResourcesToFolder to the given file with system line separator
        compact sikulixcontent format
        Parameters:
        aJar - absolute path to an existing jar or a string identifying the jar on classpath (no leading /)
        folder - path of the subtree relative to root with leading /
        targetFolder - the folder where to store the file sikulixcontent (if null, only list - no export)
        filter - implementation of interface FilenameFilter or null for no filtering
        Returns:
        success
      • resourceListAsString

        public String resourceListAsString​(String folder,
                                           FilenameFilter filter)
        write the list produced by calling extractResourcesToFolder to the returned string with system line separator
        non-compact format: every file with full path
        Parameters:
        folder - path of the subtree relative to root with leading /
        filter - implementation of interface FilenameFilter or null for no filtering
        Returns:
        the resulting string
      • resourceListAsString

        public String resourceListAsString​(String folder,
                                           FilenameFilter filter,
                                           String separator)
        write the list produced by calling extractResourcesToFolder to the returned string with given separator
        non-compact format: every file with full path
        Parameters:
        folder - path of the subtree relative to root with leading /
        filter - implementation of interface FilenameFilter or null for no filtering
        separator - to be used to separate the entries
        Returns:
        the resulting string
      • listFilesInJar

        public List<String> listFilesInJar​(URL uJar)
      • dumpClassPath

        public void dumpClassPath()
        print the current classpath entries to sysout
      • dumpClassPath

        public void dumpClassPath​(String filter)
        print the current classpath entries to sysout whose path name contain the given string
        Parameters:
        filter - the fileter string
      • isJarOnClasspath

        public String isJarOnClasspath​(String artefact)
      • isOnClasspath

        public String isOnClasspath​(String artefact)
      • fromClasspath

        public URL fromClasspath​(String artefact)
      • isOnClasspath

        public boolean isOnClasspath​(URL path)
        check wether a the given URL is on classpath
        Parameters:
        path - URL to look for
        Returns:
        true if found else otherwise
      • addToClasspath

        public boolean addToClasspath​(String jarOrFolder)
      • addToClasspath

        public boolean addToClasspath​(String jarOrFolder,
                                      String caller)
      • asExtension

        public File asExtension​(String fpJar)
      • runcmd

        public String runcmd​(String cmd)
        run a system command finally using Java::Runtime.getRuntime().exec(args) and waiting for completion
        Parameters:
        cmd - the command as it would be given on command line, quoting is preserved
        Returns:
        the output produced by the command (sysout [+ "*** error ***" + syserr] if the syserr part is present, the command might have failed
      • runcmd

        public String runcmd​(String[] args)
        run a system command finally using Java::Runtime.getRuntime().exec(args) and waiting for completion
        Parameters:
        args - the command as it would be given on command line splitted into the space devided parts, first part is the command, the rest are parameters and their values
        Returns:
        the output produced by the command (sysout [+ "*** error ***" + syserr] if the syserr part is present, the command might have failed
      • getLastCommandResult

        public String getLastCommandResult()