public static void main()

in apm-agent-attach-cli/src/main/java/co/elastic/apm/attach/AgentAttacher.java [105:153]


    public static void main(String[] args) {
        Arguments arguments;
        try {
            arguments = Arguments.parse(args);
            if (arguments.isHelp()) {
                Arguments.printHelp(System.out);
                return;
            }
        } catch (IllegalArgumentException e) {
            System.out.println(e.getMessage());
            Arguments.printHelp(System.out);
            return;
        }
        Logger logger = initLogging(arguments);

        if (logger.isDebugEnabled()) {
            logger.debug("attach process started with:  user = '{}', current directory = {}", System.getProperty("user.name"), System.getProperty("user.dir"));
        }

        String downloadAgentVersion = arguments.getDownloadAgentVersion();
        if (downloadAgentVersion == null && arguments.getAgentJar() == null) {
            // If there is no bundled agent and a path for agent was not specified, default to download the latest
            downloadAgentVersion = LATEST_VERSION;
        }
        if (downloadAgentVersion != null) {
            try {
                downloadAndVerifyAgent(arguments, downloadAgentVersion);
            } catch (Exception e) {
                logger.error(String.format("Failed to download requested agent version %s, please double-check your " +
                    "--download-agent-version setting.", downloadAgentVersion), e);
                System.exit(1);
            }
        }

        if (arguments.getAgentJar() == null) {
            logger.error("Cannot find agent jar. When using the slim jar, either the --agent-jar or the " +
                "--download-agent-version arguments are required");
            System.exit(1);
        }

        if (logger.isDebugEnabled()) {
            logger.debug("attacher arguments : {}", arguments);
        }
        try {
            new AgentAttacher(arguments).doAttach();
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
        }
    }