如何检测linux机器上是否安装了tomcat和ant

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14995936/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 19:05:06  来源:igfitidea点击:

How to detect whether tomcat and ant are installed on linux machine

linuxapachetomcatantversion

提问by Shiva Krishna Bavandla

I am trying to install Tomcatand Anton my linux machine, but before installing them i just need to check whether they are already installed or not.

我正在尝试在我的 linux 机器上安装TomcatAnt,但在安装它们之前,我只需要检查它们是否已经安装。

Regarding tomcat:

关于 tomcat

I googled a lot and searched on my machine in the following directories for tomcat

我用谷歌搜索了很多,并在我的机器上在以下目录中搜索了 tomcat

/usr/local/, /opt/, /usr/share/

but i din't find tomcat folder in any of the above path, whether it indicates that tomcatis not installed ? so actually

但是我在上面的任何一个路径中tomcat都没有找到tomcat文件夹,是否表明没有安装?所以实际上

1. what is the path to `look/find` exactly to know/check whether tomcat is installed or not in 
   all linux machines
2. what will be the path the tomcat will be installed exactly after installation
3. How to find the version of tomcat on any linux machine (if tomcat already installed) 
4. Whether there are any commands to look for both whether `tomcat` installed and `ant` 
   installed

Regarding Ant:

关于蚂蚁

I googled and got the below command due to which i got the below result after executing it

我用谷歌搜索并得到了以下命令,因此我在执行后得到了以下结果

sh-4.2$ ant -v

result

结果

sh-4.2$ ant -v
Apache Ant(TM) version 1.8.2 compiled on November 21 2011
Trying the default build file: build.xml
Buildfile: build.xml does not exist!
Build failed

so actually

所以实际上

1. Does the above result mean that `Ant` is installed ? or not ?
2. what is the path to `look/find` exactly to know/check whether ant is installed or not in 
   all linux machines
3. what will be the path the `ant` will be installed exactly after installation
4. How to find the version of `Ant` on any linux machine (if Ant already installed) 

采纳答案by StarPinkER

Generally, you can check whether they are on the $PATH, if they are not on the $PATH, install one.

一般情况下,你可以检查它们是否在$PATH 上,如果它们不在$PATH 上,则安装一个。

For ant:

对于蚂蚁:

ant -vstands for verbose, ant -versionprints out its version.

ant -v代表详细,ant -version打印出它的版本。

   -help, -h
          print help on the command line options

   -projecthelp, -p
          gives information on possible targets for this project

   -version
          prints the version number and then exits ant

   -quiet, -q
          be extra quiet

   -verbose, -v
          be extra verbose

   -debug, -d
          print debugging information

   -emacs, -e
          produce logging information without adornments

   -logfile <file>, -l <file>
          use the given file to output log to

   -logger <classname>
          the class which is to perform logging

   -listener <classname>
          add an instance of the given class as a project listener

   -noinput
          do not allow interactive input

   -buildfile <file>, -file <file>, -f <file>
          use  the  given buildfile instead of the default build.xml file.
          This is the ant equivalent of Makefile

   -D<property>=<value>
          use value for the given property

   -keep-going, -k
          execute all targets that do not depend on failed target(s)

   -propertyfile <file>
          load all properties from file with -D properties  taking  prece-
          dence

   -inputhandler <class>
          the class which will handle input requests

   -find <file>, -s <file>
          (s)earch  for  buildfile  towards the root of the filesystem and
          use it

   -nice number
          A niceness value for the main thread: 1 (lowest)  to  10  (high-
          est); 5 is the default

   -nouserlib
          Run ant without using the jar files from ${user.home}/.ant/lib

   -noclasspath
          Run ant without using CLASSPATH

   -autoproxy
          Java 1.5+ : use the OS proxies

   -main <class>
          override ant's normal entry point

For tomcat:

对于Tomcat:

if tomcat/bin is on the $PATH variable, version.sh will print out the version.

如果 tomcat/bin 在 $PATH 变量上,version.sh 将打印出版本。

回答by Imranmadbar

For linux ubuntu 18.04:

对于 linux ubuntu 18.04:

Go to terminal and command:$ sudo systemctl status tomcat

This command also show is tomcat running or not (if already installed)

此命令还显示 tomcat 是否正在运行(如果已安装)