如何使用CMD启动停止tomcat服务器?

发布于 2024-10-08 18:41:51 字数 550 浏览 0 评论 0原文

我设置了 tomcat 的路径并设置了所有变量,例如

  1. JAVA_HOME=C:\Program Files (x86)\Java\jdk1.6.0_22
  2. CATALINA_HOME=G:\springwork\server\apache- tomcat-6.0.29
  3. CLASSPATH=G:\springwork\server\apache-tomcat-6.0.29\lib\servlet-api.jar;G:\springwork\server\apache-tomcat-6.0。 29\lib\jsp-api.jar;.;

当我进入 bin 文件夹并双击startup.bat 时,我的tomcat 启动,当我双击shutdown.bat 时,tomcat 停止。

但我想使用CMD启动和停止tomcat。 在我编写命令 startup.bat 的任何文件夹中,服务器将启动,当我编写 shutdown.bat 时,服务器将停止。

I set the path for the tomcat and set all variables like

  1. JAVA_HOME=C:\Program Files (x86)\Java\jdk1.6.0_22
  2. CATALINA_HOME=G:\springwork\server\apache-tomcat-6.0.29
  3. CLASSPATH=G:\springwork\server\apache-tomcat-6.0.29\lib\servlet-api.jar;G:\springwork\server\apache-tomcat-6.0.29\lib\jsp-api.jar;.;

When I go to bin folder and double click on startup.bat then my tomcat starts and when I double click on shutdown.bat tomcat stops.

But I want using CMD start and stop the tomcat.
And in any folder I write command startup.bat the server will start and when I write shutdown.bat the server will stop.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

傲娇萝莉攻 2024-10-15 18:41:51

%CATALINA_HOME%/bin 添加到路径系统变量。

转到系统变量下的环境变量屏幕,会有一个Path变量,编辑变量并添加;%CATALINA_HOME%\bin< /code> 到变量,然后单击确定 保存更改。关闭所有打开的命令提示符,然后打开新的命令提示符并尝试使用命令 startup.bat

Add %CATALINA_HOME%/bin to path system variable.

Go to Environment Variables screen under System Variables there will be a Path variable edit the variable and add ;%CATALINA_HOME%\bin to the variable then click OK to save the changes. Close all opened command prompts then open a new command prompt and try to use the command startup.bat.

只怪假的太真实 2024-10-15 18:41:51

使用 cmd 启动 Apache Tomcat 的步骤:
1.首先检查JRE_HOME或JAVA_HOME是否是环境变量中可用的变量。(如果不是则创建新变量JRE_HOME或JAVA_HOME)
2. 转到 cmd 并将工作目录更改为安装(或解压)apache 的 bin 路径。
3. 输入命令 -> catalina.bat start 用于启动服务器。
4. 输入命令 -> catalina.bat stop 用于停止服务器。

Steps to start Apache Tomcat using cmd:
1. Firstly check that the JRE_HOME or JAVA_HOME is a variable available in environment variables.(If it is not create a new variable JRE_HOME or JAVA_HOME)
2. Goto cmd and change your working directory to bin path where apache is installed (or extracted).
3. Type Command -> catalina.bat start to start the server.
4. Type Command -> catalina.bat stop to stop the server.

怎言笑 2024-10-15 18:41:51

这是我用来启动和停止 tomcat 7.0.29 的方法,使用 ant 1.8.2。对我来说效果很好,但将控件留在启动的服务器窗口中。我还没有尝试过,但我想如果我将启动顺序中的“/K”更改为“/C”,它甚至可能无法做到这一点。

<target name="tomcat-stop">
    <exec dir="${appserver.home}/bin" executable="cmd">
        <arg line="/C start cmd.exe /C shutdown.bat"/>
    </exec>
</target>



<target name="tomcat-start" depends="tomcat-stop" >
    <exec dir="${appserver.home}/bin" executable="cmd">
        <arg line="/K start cmd.exe /C startup.bat"/>
    </exec>

</target>

This is what I used to start and stop tomcat 7.0.29, using ant 1.8.2. Works fine for me, but leaves the control in the started server window. I have not tried it yet, but I think if I change the "/K" in the startup sequence to "/C", it may not even do that.

<target name="tomcat-stop">
    <exec dir="${appserver.home}/bin" executable="cmd">
        <arg line="/C start cmd.exe /C shutdown.bat"/>
    </exec>
</target>



<target name="tomcat-start" depends="tomcat-stop" >
    <exec dir="${appserver.home}/bin" executable="cmd">
        <arg line="/K start cmd.exe /C startup.bat"/>
    </exec>

</target>
何以笙箫默 2024-10-15 18:41:51

在 Linux 和 Windows 操作系统中启动和停止 Apache Tomcat 服务器的方法有多种。以下是详细事实。找到 tomcat 服务器中的 bin 文件夹,然后在 CMD/ 终端中执行以下命令。

Linux:

./catalina.sh run

为 catalina.sh 传递“run”参数 -->在前台启动Tomcat,并在同一控制台显示运行日志。当控制台终端关闭时,将终止 tomcat

./catalina.sh start | ./catalina.sh stop

为 catalina.sh 传递“start”参数 --> 在后台启动 Tomcat。由于在后台关闭终端没有问题。日志需要如下查看: tail -f $CATALINA_HOME/logs/catalina.out

./startup.sh | ./shutdown.sh 

最后一种方法是触发startup.sh 来启动Tomcat 服务器。如果您 Vi 该脚本,您可以看到它调用 catalina.sh 脚本并传递 start 作为参数。这也将在后台运行。

Windows:

startup.bat // start tomcat server
shutdown.bat // stop tomcat server

There are multiple ways to Start and Stop Apache Tomcat Server in Linux and Windows Operating systems. Below is detail facts. Locate the bin folder in your tomcat server and execute the following commands in CMD/ Terminal.

Linux:

./catalina.sh run

Passing "run" argument for catalina.sh --> starts the Tomcat in the foreground and displays the running logs in the same console. when the console terminal is closed it will terminate the tomcat.

./catalina.sh start | ./catalina.sh stop

Passing "start" argument for catalina.sh --> starts the Tomcat in the background. Since in background no issues closing down the terminal. The logs need to be viewed as below: tail -f $CATALINA_HOME/logs/catalina.out

./startup.sh | ./shutdown.sh 

The last way is firing the startup.sh to start your Tomcat server. If you Vi the script you can see it calls catalina.sh script passing start as the argument. This will be running in background as well.

Windows:

startup.bat // start tomcat server
shutdown.bat // stop tomcat server
波浪屿的海角声 2024-10-15 18:41:51

您可以使用此技巧使用 cmd 并直接通过 tomcat bin 文件夹运行 tomcat。

1.
设置jdk的路径。

2.

设置路径。
转到桌面并右键单击计算机图标。
单击属性

转到高级系统设置。

然后单击“高级”到“环境变量”。

点击新建并设置路径AS,

变量名=JAVA_HOME列中

变量值=C:\Program Files\Java\jdk1.6.0_19

点击ok ok。

现在路径已设置。

3.

转到安装 tomcat 的 tomcat 文件夹。
转到 bin 文件夹。
有两个窗口批处理文件。

1.启动

2.关闭。

通过使用cmd
如果您将 tomcate 安装在 D 驱动器中,

请在 cmd 屏幕上输入

  1. D:

  2. cd tomcat\bin
    然后输入
    用于 Windows 的启动.bat
    和 ./startup.sh(适用于 Linux)

通过单击它们,您可以启动和停止 tomcat。

5.

最后一步。

如果您开始并想检查它。

在 URL 栏类型中打开浏览器。

**HTTP://localhost:8080/**

you can use this trick to run tomcat using cmd and directly by tomcat bin folder.

1.
set the path of jdk.

2.

To set path.
go to Desktop and right click on computer icon.
Click the Properties

go to Advance System Settings.

then Click Advance to Environment variables.

Click new and set path AS,

in the column Variable name=JAVA_HOME

Variable Value=C:\Program Files\Java\jdk1.6.0_19

Click ok ok.

now path is setted.

3.

Go to tomcat folder where you installed the tomcat.
go to bin folder.
there are two window batch files.

1.Startup

2.Shutdown.

By using cmd
if you installed the tomcate in D Drive

type on cmd screen

  1. D:

  2. Cd tomcat\bin
    then type
    startup.bat for Windows
    and ./startup.sh for Linux

By clicking them you can start and stop the tomcat.

5.

Final step.

if you start and want to check it.

open a Browser in URL bar type.

**HTTP://localhost:8080/**
九局 2024-10-15 18:41:51

在cmd提示符下将目录更改为tomcat/bin目录

cd C:\Program Files\Apache Software Foundation\Tomcat 8.0\bin

运行以下命令启动:

在 Linux 上:>startup.sh

在 Windows 上:>startup.bat

运行这些命令 >停止

在 Linux 上:shutdown.sh

在 Windows 上:shutdown.bat

Change directory to tomcat/bin directory in cmd prompt

cd C:\Program Files\Apache Software Foundation\Tomcat 8.0\bin

Run the below command to start:

On Linux: >startup.sh

On Windows: >startup.bat

Run these commands to stop

On Linux: shutdown.sh

On Windows: shutdown.bat

旧人 2024-10-15 18:41:51

创建一个 .bat 文件并写入两个命令:

cd C:\ Path to your tomcat directory \ bin

startup.bat

现在双击,Tomcat 服务器将启动。

Create a .bat file and write two commands:

cd C:\ Path to your tomcat directory \ bin

startup.bat

Now on double-click, Tomcat server will start.

亽野灬性zι浪 2024-10-15 18:41:51

我刚刚下载了 Tomcat,想停止它 (Windows)。

  1. 停止tomcat

    • 以管理员身份运行cmd(我使用的是Cmder)

    • 查找进程ID

tasklist /fi "Imagename eq tomcat*"

C:\Users\Admin
tasklist /fi "Imagename eq tomcat*"

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
Tomcat8aaw.exe                6376 Console                    1      7,300 K
Tomcat8aa.exe                 5352 Services                   0    124,748 K
  • stop prosess with pid 6376

C:\Users\Admin

taskkill /f /pid 6376

成功:PID 6376 的进程已终止。

  • 停止 pid 5352 的进程

C:\Users\Admin

taskkill /f /pid 5352

成功: PID 5352 的进程已终止。

I have just downloaded Tomcat and want to stop it (Windows).

  1. To stop tomcat

    • run cmd as administrator (I used Cmder)

    • find process ID

tasklist /fi "Imagename eq tomcat*"

C:\Users\Admin
tasklist /fi "Imagename eq tomcat*"

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
Tomcat8aaw.exe                6376 Console                    1      7,300 K
Tomcat8aa.exe                 5352 Services                   0    124,748 K
  • stop prosess with pid 6376

C:\Users\Admin

taskkill /f /pid 6376

SUCCESS: The process with PID 6376 has been terminated.

  • stop process with pid 5352

C:\Users\Admin

taskkill /f /pid 5352

SUCCESS: The process with PID 5352 has been terminated.

老旧海报 2024-10-15 18:41:51

您可以使用以下命令
c:\tomcat目录路径\bin>catalina run

You can use the following command
c:\path of you tomcat directory\bin>catalina run

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文