mav
mav

Reputation: 129

How to find where Tomcat is install/running from when it is not installed as a service

I'm trying to determine the Tomcat install directory when it is started from startup.bat in Windows.

It is easy enough to determine where tomcat7.exe is running when Tomcat is running as a service, but I'm not sure how to do it when it's started with the script. I know java is running when Tomcat is started from the script, but the executable path is for the java jre. Is there something I can do to find where catalina is running based on java?

Upvotes: 1

Views: 1370

Answers (2)

Luiggi Mendoza
Luiggi Mendoza

Reputation: 85779

Assuming you know the location of startup.bat, then just go two folders above and you're done.

Assuming you only have a shortcut to this file, then you would need to retrieve a list of processes explaining the application and the location of the files they're using, similar like ps aux command from Unix based OSes. Fortunately, Windows have such thing as well. From this great Q/A: Is there a command in Windows like ps -aux in UNIX?, more specifically, this answer, the way to find the location of tomcat in Windows is to execute the wmic application (through CMD if you want) and write process command, this will provide a list of the current applications running and their parameters. For example, I initialized Tomcat from startup.bat file and got this result using the commands above (single line):

java.exe                     "C:\Program Files\Java\jdk1.7.0_40\bin\java"   -Djava.util.logging.config.file="<TOMCAT_HOME>\conf\logging.properties" -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager   -Djava.endorsed.dirs="<TOMCAT_HOME>\endorsed" -classpath "<TOMCAT_HOME>\bin\bootstrap.jar;<TOMCAT_HOME>\bin\tomcat-juli.jar" -Dcatalina.base="<TOMCAT_HOME>" -Dcatalina.home="<TOMCAT_HOME>" -Djava.io.tmpdir="<TOMCAT_HOME>\temp" org.apache.catalina.startup.Bootstrap  start

Here's the same result but splitted in several lines to ease readability:

java.exe "C:\Program Files\Java\jdk1.7.0_40\bin\java"
    -Djava.util.logging.config.file="<TOMCAT_HOME>\conf\logging.properties"
    -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
    -Djava.endorsed.dirs="<TOMCAT_HOME>\endorsed"
    -classpath "<TOMCAT_HOME>\bin\bootstrap.jar;<TOMCAT_HOME>\bin\tomcat-juli.jar"
    -Dcatalina.base="<TOMCAT_HOME>"
    -Dcatalina.home="<TOMCAT_HOME>"
    -Djava.io.tmpdir="<TOMCAT_HOME>\temp"
    org.apache.catalina.startup.Bootstrap  start

Note: I've replaced the real path by <TOMCAT_HOME> in the results from above.


TL;DR do this:

  • Open cmd
  • Execute wmic
  • Execute process
  • Wait few secs and search java.exe and the arguments containing Tomcat jars.

Upvotes: 1

Dibsyhex
Dibsyhex

Reputation: 117

Since you explicitly mentioned *.bat and Windows here is your answer.

1.Most tomcat application comes as a zip instead as msi/exe . The place where you extract is actually its locations . You start the application by clicking startup.bat file

2.Open the bat file with notepad . You will also find the relative path of the application.

3.Look for the path variables .

Hope this information helps

Upvotes: 0

Related Questions