Hazelcast Command Line is released!
Tags: hazelcast, java, cli, distributedsystems
Published: 2021-02-24 13:37:41

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0gbck1zkxfr0hfdz464h.png)

We are pleased to announce that Hazelcast Command Line 4.2020.12 is now available. It supports Hazelcast IMDG 4.1.1 and Hazelcast Management Center 4.2020.12. It took longer than anticipated to get a proper CLI for Hazelcast, however, we hope you will find it was worth the wait.

In this blog post, we will go through what problems we aim to solve with Hazelcast CLI, as well as how to use it. If you're more of a hands-on learned, feel free to skip directly to the end for tips on using it.
<h2>Installing and starting an Hazelcast instance, the long way</h2>
As you most likely know, you can use Hazelcast in two main topologies: Embedded and Client-Server. You add Hazelcast as a dependency to your Java application if you choose the former architecture.

But, if you would like to design your architecture using a client-server approach, you need to start Hazelcast member instances. Before the Hazelcast CLI, you had to perform multiple steps to run a Hazelcast member standalone.
<h3>Install Java</h3>
Since Hazelcast member is a Java application, it requires a JRE to be installed in the environment. If you are not familiar with Java, it might be difficult to find the proper version and install it.
<h3>Download Hazelcast distribution</h3>
Hazelcast is available for download at <a href="https://hazelcast.com/get-started/">https://hazelcast.com/get-started/</a>. You had to visit this page and download the Hazelcast version distribution that you would like to install.
<h3>Run the instance using start.sh script</h3>
After downloading the distribution, you had to extract it to a proper location and then run the <em>“start.sh”</em> script that resides in the <em>“bin/”</em> directory.

After all these steps complete successfully, you (finally) have a running Hazelcast member instance.

However, this method is a manual process. There is support for neither package managers nor version control. Moreover, installing <a href="https://hazelcast.org/imdg/download/#hazelcast-management-center">Hazelcast Management Center</a> requires the same steps again.
<h2>The easy way: using Hazelcast Command Line</h2>
To make the Hazelcast installation easier, we developed Hazelcast Command Line. Please note that it is only targeted at developers and <em><strong>not</strong></em> recommended for usage in production environments for the time being. Now, you only need to use your favourite package manager to install Hazelcast, and then run the <code>hz start</code> command to start a Hazelcast member instance!

Even better, we have deployed the CLI in the most common repository managers.
<h3>Install with Homebrew</h3>
To install with Homebrew, you first need to tap the <em>hazelcast/hz</em> repository. Once you’ve tapped the repo, you can use brew install to install:
<pre>$ brew tap hazelcast/hz
$ brew install hazelcast</pre>
<h3>Install with yum/dnf</h3>
The RPM packages for Hazelcast Command Line are kept in Hazelcast's RPM repository. Just run the following commands to install it using <em>yum/dnf</em>:
<pre>$ wget https://repository.hazelcast.com/rpm/hazelcast-rpm.repo -O hazelcast-rpm.repo
$ sudo mv hazelcast-rpm.repo /etc/yum.repos.d/
$ sudo yum install hazelcast</pre>
<h3>Install with apt</h3>
You can find the Debian packages for Hazelcast Command Line in Hazelcast's Debian repository. Run the following commands to install it using <em>apt</em>:
<pre>$ wget -qO - https://repository.hazelcast.com/api/gpg/key/public | sudo apt-key add -
$ echo "deb https://repository.hazelcast.com/debian stable main" | sudo tee -a /etc/apt/sources.list
$ sudo apt update &amp;&amp; sudo apt install hazelcast</pre>
All these package managers will handle the Java dependencies for you. Also, you can pick the previous versions by using the proper commands for each package manager.

After the installation, run the following command to see everything is completed successfully:
<pre>$ hz
Hazelcast IMDG 4.1.1
Usage: hz [-hV] [COMMAND]
Utility for the Hazelcast operations.

Global options are:

  -h, --help Show this help message and exit.
  -V, --version Print version information and exit.
Commands:
  start Starts a new Hazelcast IMDG member
  mc Utility for Hazelcast Management Center operations.</pre>
<h2></h2>
<h2>A quick intro to Hazelcast CLI</h2>
The main command of Hazelcast Command Line is <code>hz</code>. To start a Hazelcast instance, just run <code>hz start</code> and a new instance will run with the <em>default</em> configuration:
<pre>$ hz start
Aug 21, 2020 1:40:04 PM com.hazelcast.config.FileSystemYamlConfig
INFO: Configuring Hazelcast from '/Users/myuser/hazelcast-command-line/distro/build/dist/config/hazelcast.yaml'.
...</pre>
If you want to configure the instance with an external Hazelcast configuration file, use <code>-c</code> option with the command as below:
<pre>$ hz start -c /full/path/to/config-file.yaml</pre>
The <code>-h</code> option reveals further available options:
<pre>$ hz start -h
Usage: hz start [-hvV] [-vv] [-c=&lt;file&gt;] [-i=&lt;interface&gt;] [-p=&lt;port&gt;] [-j=&lt;path&gt;
                [,&lt;path&gt;...]]... [-J=&lt;option&gt;[,&lt;option&gt;...]]...
Starts a new Hazelcast IMDG member
  -h, --help Show this help message and exit.
  -V, --version Print version information and exit.
  -c, --config=&lt;file&gt; Use &lt;file&gt; for Hazelcast configuration. Accepted
      formats are XML and YAML.
  -p, --port=&lt;port&gt; Bind to the specified &lt;port&gt;. Please note that if the
      specified port is in use, it will auto-increment to
      the first free port. (default: 5701)
  -i, --interface=&lt;interface&gt;
      Bind to the specified &lt;interface&gt;.
  -j, --jar=&lt;path&gt;[,&lt;path&gt;...]
      Add &lt;path&gt; to Hazelcast classpath (Use ',' to separate
      multiple paths). You can add jars, classes, or the
      directories that contain classes/jars.
  -J, --JAVA_OPTS=&lt;option&gt;[,&lt;option&gt;...]
      Specify additional Java &lt;option&gt; (Use ',' to separate
      multiple options).
  -v, --verbose Output with FINE level verbose logging.
  -vv, --vverbose Output with FINEST level verbose logging.</pre>
As we mentioned above, you can also start a Hazelcast Management Center using Hazelcast Command Line. Please run the following command to start a Hazelcast Management Center instance:
<pre>$ hz mc start</pre>
If you would like to start a Hazelcast Management Center with custom context path and port, please run the following command:
<pre>$ hz mc start -c [new-context-path] -p [port]</pre>
<h2>Future</h2>
Currently, Hazelcast CLI is only targeted at developers and <em><strong>not</strong></em> recommended for usage in production environments. Also, there is no support for Windows environments. We are working on them and will include more features in future releases.

Your feedback as a user is very valuable to us. We would appreciate your thoughts and feedback with us by creating an issue on <a href="https://github.com/hazelcast/hazelcast-command-line/issues">Hazelcast Command Line Github repository</a>.