๐ŸŒ
Baeldung
baeldung.com โ€บ home โ€บ java โ€บ intro to the apache commons cli
Intro to the Apache Commons CLI | Baeldung
February 20, 2025 - In this tutorial, weโ€™ll explore the Java Apache Commons CLI library. Itโ€™s a framework that empowers developers by helping them build the command line interface (CLI) of existing software tools in an efficient and standard way.
๐ŸŒ
Apache Commons
commons.apache.org โ€บ cli
Apache Commons CLI โ€“ Apache Commons CLI
November 8, 2025 - The Apache Commons CLI library provides an API for parsing command-line options passed to an application. It can also print help detailing the options available for that application ยท Commons CLI supports different types of options:
๐ŸŒ
DZone
dzone.com โ€บ coding โ€บ java โ€บ java command-line interfaces (part 1): apache commons cli
Java Command-Line Interfaces (Part 1): Apache Commons CLI
June 22, 2017 - Learn about using the Apache Commons CLI Option.Builder for the definition stage, parsing command-line options with the Commons CLI, and more.
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ commons_cli โ€บ commons_cli_quick_guide.htm
Apache Commons CLI - Quick Guide
Option object is used to represent the Option passed to command line program. Following are various properties that an Option object possess. Let's create a sample console based application, whose purpose is to get sum of passed numbers based on the option used. package com.tutorialspoint; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLineParser; import org.apache.commons.cli.DefaultParser; import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; public class CLITester { public static void main(
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ commons_cli โ€บ index.htm
Apache Commons CLI Tutorial
This tutorial is tailored for readers who aim to understand and utilize Apache Commons CLI utilities. In this tutorial, we'll cover all the ways of using Apache Common CLI which helps in solving the common problems developers/users face during ...
๐ŸŒ
Apache Commons
commons.apache.org โ€บ exec โ€บ commandline.html
Apache Commons Exec - Building the command line โ€“ Apache Commons Exec
No matter which approach you are using commons-exec does change your command line arguments in the following two cases ยท The following executable arguments
๐ŸŒ
HowTech
howtech.tv โ€บ home โ€บ how to start apache from command line
How to Start Apache from Command Line - HowTech
July 8, 2013 - In this tutorial, we will guide you on how to start apache from command line. In this tutorial, we will teach you how to check whether the apache service is working or not. Furthermore, we will teach you how to work with apache in the command line, how to make changes to the httpd configuration ...
๐ŸŒ
TecAdmin
tecadmin.net โ€บ common-apache-commands-on-ubuntu-debian
Common Apache Commands on Ubuntu & Debian โ€“ TecAdmin
April 26, 2025 - In this tutorial, we will discuss ... host, module, or configuration file in the Apache server. Use -v command-line option to check the running Apache version ......
๐ŸŒ
Linuxize
linuxize.com โ€บ home โ€บ apache โ€บ apache commands: manage and troubleshoot your web server
Apache Commands: Manage and Troubleshoot Your Web Server | Linuxize
April 8, 2026 - Quick reference for essential Apache commands on Linux. Covers service control, configuration testing, modules, virtual hosts, version info, and log files.
Find elsewhere
๐ŸŒ
TecMint
tecmint.com โ€บ home โ€บ web servers โ€บ apache โ€บ useful commands to manage apache web server in linux
Useful Commands to Manage Apache Web Server in Linux
May 10, 2019 - Usage: httpd [-D name] [-d directory] [-f file] [-C "directive"] [-c "directive"] [-k start|restart|graceful|graceful-stop|stop] [-v] [-V] [-h] [-l] [-L] [-t] [-T] [-S] [-X] Options: -D name : define a name for use in directives -d directory ...
๐ŸŒ
2DayGeek
2daygeek.com โ€บ home โ€บ cheatsheet for apache2 commands
Cheatsheet For Apache2 Commands | 2DayGeek
May 4, 2020 - Cheatsheet is one of the quickest reference guides that allows you to easily find the right commands. This is very useful for a Linux administrator or developer. In this tutorial, we have added all possible commands and configuration files for the Apache 2 service, which is useful for Ubuntu/Debian ...
๐ŸŒ
GitHub
github.com โ€บ apache โ€บ commons-cli
GitHub - apache/commons-cli: Apache Commons CLI ยท GitHub
Apache Commons CLI provides a simple API for presenting, processing, and validating a Command Line Interface.
Starred by 389 users
Forked by 249 users
Languages ย  Java 97.4% | JavaScript 2.4%
๐ŸŒ
LabEx
labex.io โ€บ tutorials โ€บ linux-linux-apachectl-command-with-practical-examples-422544
Linux apachectl Command with Practical Examples | LabEx
Next, let's explore the different options available with the apachectl command: ... Usage: apachectl [option] Options: start Start the Apache httpd daemon stop Stop the Apache httpd daemon restart Restart the Apache httpd daemon graceful Gracefully restart the Apache httpd daemon graceful-stop Gracefully stop the Apache httpd daemon configtest Run a configuration syntax test status Display the status of the Apache httpd daemon fullstatus Display a full status report from mod_status help Display usage information -k start|stop|restart|graceful|graceful-stop Perform operation -v Print version and then exit -V Print version and built-in modules, then exit -t Run configuration syntax test -D name Define a global variable -f file Specify an alternate ServerRoot file
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ commons_cli โ€บ commons_cli_usage_example.htm
Apache Commons CLI - Usage Example
package com.tutorialspoint; import java.io.IOException; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLineParser; import org.apache.commons.cli.DefaultParser; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; import org.apache.commons.cli.help.HelpFormatter; public class CLITester { public static void main(String[] args) throws ParseException, IOException { Options options = new Options(); options.addOption("p", "print", false, "Send print request to printer.") .addOption("g", "gui", false, "Show GUI Application") .addOption(
๐ŸŒ
GitHub
gist.github.com โ€บ jagwarthegreat โ€บ aae54e22b3b4eae4d217276c78099abe
APACHE2 COMMANDS ยท GitHub
## Start command ## systemctl start apache2.service ## Stop command ## systemctl stop apache2.service ## Restart command ## systemctl restart apache2.service
Top answer
1 of 1
3

Here's a very stripped down version of something I use. It basically sets up a singleton that gets initialized once and then can be used wherever you want within your program. I chose to store the info in HashMap's and ArrayList's because they were easier to deal with later.

//****************************************************************************
//***** File Name: MianCLIOptions.java
//****************************************************************************

package com.test.mian;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.commons.cli.AlreadySelectedException;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.GnuParser;
import org.apache.commons.cli.MissingArgumentException;
import org.apache.commons.cli.MissingOptionException;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.UnrecognizedOptionException;
import org.apache.commons.lang.WordUtils;


//****************************************************************************
//****************************************************************************
//****************************************************************************
//****************************************************************************
public class MianCLIOptions
{
    //***** constants *****

    //***** public data members *****

    //***** private data members *****
    private static MianCLIOptions singletonObj = null;

    private HashMap<String,Object> options = new HashMap<String,Object>();
    private ArrayList<String> arguments = new ArrayList<String>();

    //****************************************************************************
    public static MianCLIOptions getopts()
    {
        if (singletonObj == null) {
            throw new IllegalStateException("[MianCLIOptions] Command line not yet initialized.");
        }

        return singletonObj;
    }

    //****************************************************************************
    public static synchronized void initialize(Options optsdef, String[] args)
        throws MianCLIOptionsException, UnrecognizedOptionException, MissingArgumentException,
               MissingOptionException, AlreadySelectedException, ParseException
    {
        if (singletonObj == null) {
            singletonObj = new MianCLIOptions(optsdef, args);
        }
        else {
            throw new IllegalStateException("[MianCLIOptions] Command line already initialized.");
        }
    }

    //****************************************************************************
    //----- prevent cloning -----
    public Object clone() throws CloneNotSupportedException
    {
        throw new CloneNotSupportedException();
    }

    //****************************************************************************
    public boolean isset(String opt)
    {
        return options.containsKey(opt);
    }

    //****************************************************************************
    public Object getopt(String opt)
    {
        Object rc = null;

        if (options.containsKey(opt)) {
            rc = options.get(opt);
        }

        return rc;
    }

    //****************************************************************************
    //***** finally parse the command line
    //****************************************************************************
    private MianCLIOptions(Options optsdef, String[] args)
        throws UnrecognizedOptionException, MissingArgumentException,
               MissingOptionException, AlreadySelectedException, ParseException
    {
        //***** (blindly) parse the command line *****
        CommandLineParser parser = new GnuParser();
        CommandLine cmdline = parser.parse(optsdef, args);

        //***** store options and arguments *****
        //----- options -----
        for (Option opt : cmdline.getOptions()) {
            String key = opt.getOpt();
            if (opt.hasArgs()) {
                options.put(key, opt.getValuesList());
            }
            else {
                options.put(key, opt.getValue());
            }
        }

        //----- arguments -----
        for (String str : cmdline.getArgs()) {
            //----- account for ant/build.xml/generic -----
            if (str.length() > 0) {
                arguments.add(str);
            }
        }
    }
}

//****************************************************************************
//***** EOF  ***** EOF  ***** EOF  ***** EOF  ***** EOF  ***** EOF  **********

In your main, you can then call it like so:

    //***** build up options *****
    Options options = new Options();

    // ... .... ...

    //***** process command line *****
    try {
        MianCLIOptions.initialize(options, args);
    }
    catch (UnrecognizedOptionException ex) {
        // do something
    }

And finally, in some other class you can call it like so:

    MianCLIOptions opts = MianCLIOptions.getopts();
    if (opts.isset("someopt")) {
        // do something exciting
    }

Hope that helps!

๐ŸŒ
Medium
medium.com โ€บ nerd-for-tech โ€บ how-to-launch-an-apache-web-server-from-the-cli-5e607e47172a
How to launch an Apache Web Server from the CLI | by Marshall Hubbard | Nerd For Tech | Medium
March 26, 2022 - How to launch an Apache Web Server from the CLI Alright guys, welcome back to my blog! I decided to take you guys back to the basics and show you how to install an Apache web server directly from the โ€ฆ
๐ŸŒ
DevDojo
devdojo.com โ€บ post โ€บ serverenthusiast โ€บ 14-apache-commands-to-help-you-manage-your-server-like-a-pro
14 Apache commands to help you manage your server like a pro - DevDojo
August 19, 2020 - Apache has been the most popular web server for a very long time. You can run Apache on almost all major operating systems out there like Linux, Mac, Windows, and more. In this tutorial, you will learn 10 commands that will help you manage your Apache server like a pro!
๐ŸŒ
Lyris
lunar.lyris.com โ€บ help โ€บ lm_help โ€บ 4.0 โ€บ ApacheCommandLine.html
Apache Command Line
Lyris User's Guide [previous] [next] [contents] Apache Command Line Table of Contents Introduction Email Commands Web Interface for Users Server Administrator Site Administrator List Administrator Other Topics Add-On Packages NT Authentication Option Lyris List Manager ODBC Driver Random Document ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ linux-unix โ€บ most-useful-commands-to-manage-apache-web-server-in-linux
Most Useful Commands to Manage Apache Web Server in Linux - GeeksforGeeks
July 23, 2025 - For checking Apache configuration files for finding any syntax errors on Debian-based systems before restarting the service use the following command:- ... All the virtual hosts on the server, their options, and the file names and line numbers that they define, an error message with the line number are displayed that is very useful for troubleshooting the configuration file.