# Run Logstash using Java program

**URL:** <https://discuss.elastic.co/t/run-logstash-using-java-program/54877>\
**Category:** Logstash\
**Created:** [July 6, 2016, 10:51pm UTC](https://discuss.elastic.co/t/run-logstash-using-java-program/54877 "2016-07-06T22:51:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wldbs0508](https://avatars.discourse-cdn.com/v4/letter/w/cab0a1/32.png) [@wldbs0508](https://discuss.elastic.co/u/wldbs0508)\
**Post date:** [July 6, 2016, 10:51pm UTC](https://discuss.elastic.co/t/run-logstash-using-java-program/54877/1 "2016-07-06T22:51:55Z")

</div>

Hi,

I would like to implement a program which runs Logstash with my custom config file. I wish to implement the program based on Java language. Is there anyone knows how to do it? Do I just run command like "./logstash -f configfile.config" using Java program? Is there any api library for Java?

Thank,

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [July 6, 2016, 11:48pm UTC](https://discuss.elastic.co/t/run-logstash-using-java-program/54877/2 "2016-07-06T23:48:57Z")

</div>

> [@wldbs0508](#):
>
> I would like to implement a program which runs Logstash with my custom config file

What is the point of this?

---

<div class="post-metadata">

**Author:** ![wldbs0508](https://avatars.discourse-cdn.com/v4/letter/w/cab0a1/32.png) [@wldbs0508](https://discuss.elastic.co/u/wldbs0508)\
**Post date:** [July 6, 2016, 11:53pm UTC](https://discuss.elastic.co/t/run-logstash-using-java-program/54877/3 "2016-07-06T23:53:50Z")

</div>

Thank you for answering. I wish to run Logstash when I want. So I would like to write Java program which runs Logstash. For now, I wrote Java code using Runtime class to run this "./logstash -f configfile.config". Is there better way to run Logstash using Java code?

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [July 7, 2016, 5:57am UTC](https://discuss.elastic.co/t/run-logstash-using-java-program/54877/4 "2016-07-07T05:57:56Z")

</div>

> For now, I wrote Java code using Runtime class to run this "./logstash -f configfile.config". Is there better way to run Logstash using Java code?

Theoretically you might be able to load the Logstash jars in a new classloader and fire it up, but that's not supported. Just start Logstash like you'd do from any other language.

---

<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:** [July 6, 2017, 4:49am UTC](https://discuss.elastic.co/t/run-logstash-using-java-program/54877/5 "2017-07-06T04:49:11Z")

</div>


