# Plugin Development: access command line arguments

**URL:** <https://discuss.elastic.co/t/plugin-development-access-command-line-arguments/105607>\
**Category:** Elasticsearch\
**Created:** [October 27, 2017, 7:36pm UTC](https://discuss.elastic.co/t/plugin-development-access-command-line-arguments/105607 "2017-10-27T19:36:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Simone\_Scarduzio](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simone_scarduzio/32/17128_2.png) [@Simone\_Scarduzio](https://discuss.elastic.co/u/Simone_Scarduzio)\
**Post date:** [October 27, 2017, 7:36pm UTC](https://discuss.elastic.co/t/plugin-development-access-command-line-arguments/105607/1 "2017-10-27T19:36:31Z")

</div>

Hello,

From inside a plugin, I need to get a grip of what's the absolute path of `elasticsearch.yml`.

> **motivation** : I need my plugin's settings file to sit side-by-side in the config dir beside elasticsearch.yml

I can understand what's the path of the ES\_HOME like this:

```java
System.getProperty("es.path.home");

```

But this doesn't tell you much about the config directory is going to be. And that's because there is a command line option, namely `-Epath.conf=/x/y/z` that can move the config directory anywhere else and the plugin will know nothing about it.

Currently there is no Java API to get the "argv" command line arguments array of the current process (except for the JVM options).

So: How to get the value of `-Epath.conf` from a plugin?

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [October 27, 2017, 10:44pm UTC](https://discuss.elastic.co/t/plugin-development-access-command-line-arguments/105607/2 "2017-10-27T22:44:12Z")

</div>

You didn't mention which version of elasticsearch you are writing this plugin for. Assuming that this is something recent (5.x or above) you can get this information from `Environment`, which is passed as one of the parameters to the `createComponents` calls.

---

<div class="post-metadata">

**Author:** ![Simone\_Scarduzio](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simone_scarduzio/32/17128_2.png) [@Simone\_Scarduzio](https://discuss.elastic.co/u/Simone_Scarduzio)\
**Post date:** [October 27, 2017, 10:56pm UTC](https://discuss.elastic.co/t/plugin-development-access-command-line-arguments/105607/3 "2017-10-27T22:56:44Z")

</div>

Thanks Igor!

I noticed in 6.x it's available, but In the current 5.6.3 Environment is not yet available. Any other route?

> <https://github.com/elastic/elasticsearch/blob/v5.6.3/core/src/main/java/org/elasticsearch/plugins/Plugin.java#L108>

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [October 27, 2017, 11:10pm UTC](https://discuss.elastic.co/t/plugin-development-access-command-line-arguments/105607/4 "2017-10-27T23:10:58Z")

</div>

Yes, in 5.x you need to do [this](https://github.com/elastic/elasticsearch/blob/6050f225c1915ea966230f9ad3a7665c7d838c8a/plugins/jvm-example/src/main/java/org/elasticsearch/plugin/example/JvmExamplePlugin.java#L46):

```auto
public class JvmExamplePlugin extends Plugin implements ActionPlugin {
    /* ..... */

    public JvmExamplePlugin(Settings settings) {
        Environment environment = new Environment(settings);
        /* ..... */
     }

     /* ..... */
}

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 24, 2017, 11:11pm UTC](https://discuss.elastic.co/t/plugin-development-access-command-line-arguments/105607/5 "2017-11-24T23:11:06Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
