How to unistall logstash using yum on CentOS

I am using logstash on apache server on my AWS instance.

Did you install it via the RPM package? If so, just type

yum remove logstash

and you should be good.

When I try to reinstall logstash this comes up:` Installing : 1:logstash-7.4.2-1.noarch 1/1
Using provided startup.options file: /etc/logstash/startup.options
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/jruby/Main : Unsupported major.minor version 52.0
at java.lang.ClassLoader.findBootstrapClass(Native Method)
at java.lang.ClassLoader.findBootstrapClassOrNull(ClassLoader.java:1078)
at java.lang.ClassLoader.loadClass(ClassLoader.java:419)
at java.lang.ClassLoader.loadClass(ClassLoader.java:417)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:323)
at java.lang.ClassLoader.loadClass(ClassLoader.java:363)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
Verifying : 1:logstash-7.4.2-1.noarch 1/1

Installed:
logstash.noarch 1:7.4.2-1 `

Looks like a Java issue: see for example this Github issue, with an almost identical exception message.

Can you check is JDK/JRE is correctly installed and configured?