Soumyadeep Auddy
Soumyadeep Auddy

Reputation: 3

How to find tomcat version in registry editor?

Some existing answers say to go to SOFTWARE\Apache Software Foundation\TomcatVERSION

But I cant find any tomcatVersion directory

I do have

SOFTWARE\Apache Software Foundation\Tomcat\9.0\Tomcat9

Inside this, there is a version attribute which tells that the tomcat version is 9

but the target folder location changes with version. If I have tomcat8, the target folder location is

SOFTWARE\Apache Software Foundation\Tomcat\8.0\Tomcat8

I need a fixed path that will tell me the existing tomcat version on my device. Thanks in advance.

Upvotes: 0

Views: 2492

Answers (2)

Mark Thomas
Mark Thomas

Reputation: 16615

You can't. There is no path that will tell you the exact Apache Tomcat version installed. You have several options.

There is a version.[bat|sh] script in $CATALINA_HOME/bin that will report the exact Tomcat version along with OS and JVM info. This requires that the JAVA_HOME environment variable is correctly set.

If you look in the /META-INF/MANIFEST.MF file in $CATALINA_HOME/lib/catalina.jar you will find an Implementation-Version field that lists the exact version. Note that the specification JARs report the specification implementation version, not the Tomcat version so you can;t just pick any JAR.

You will also find version information at /org/apache/catalina/util/ServerInfo.properties in $CATALINA_HOME/lib/catalina.jar.

The full version information is also reported in the logs when Tomcat starts.

Upvotes: 1

Costa
Costa

Reputation: 2874

I am posting this to maybe inspire others.

I had a very dumb idea that just might work, calling the powershell and getting the tomcat version with a command, then reading the output so you can do what you want with it.

Please note this code is a jugaad!

using (Process process = new Process())
{
    process.StartInfo.FileName = "powershell.exe";
    process.StartInfo.Arguments = "(get-service Tomcat*).DisplayName";
    process.StartInfo.UseShellExecute = false;
    process.StartInfo.RedirectStandardOutput = true;
    process.Start();

    // Synchronously read the standard output of the spawned process.
    StreamReader reader = process.StandardOutput;
    string output = reader.ReadToEnd();

    process.WaitForExit();

    //do whatever you want with output (such as string manipulation) here
}

Posts that helped me: here and here

Upvotes: 0

Related Questions