简体   繁体   English

Tomcat中的独立应用程序

[英]Standalone application inside tomcat

I have a simple java class that i want to run programmatically. 我有一个想以编程方式运行的简单Java类。 This is basically a video player. 这基本上是一个视频播放器。 It is also deployed along with my web application in tomcat. 它还与我的Web应用程序一起部署在tomcat中。 This should run upon a click on a particular link. 这应该在单击特定链接时运行。 From controller, here's how I run it 在控制器中,这是我的运行方式

new Thread(() -> { VideoPlayer.main(new String[]{}); }).start(); new Thread(()-> {VideoPlayer.main(new String [] {});})。start();

It is working fine. 一切正常。 But every time I close the Video player, tomcat is also terminated. 但是每次关闭视频播放器时,tomcat也将终止。 Any ideas on how to correct this? 关于如何纠正这一点的任何想法?

Your GUI probably calls System.exit when you close it. 关闭它时,GUI可能会调用System.exit That'll take-down Tomcat since they are both running in the same JVM. 这将删除Tomcat,因为它们都在同一个JVM中运行。 Find and remove the System.exit and you'll find things work-out better for you. 找到并删除System.exit ,您会发现事情对您而言更好。

Also note that it doesn't make any sense for a web application to launch a video player. 另请注意,对于Web应用程序而言,启动视频播放器没有任何意义。 Think about it: once the web application is no longer running on your own personal development workstation, the video will be played on the server where there isn't anyone to watch it. 想想看:一旦Web应用程序不再在您自己的个人开发工作站上运行,该视频将在没有人观看的服务器上播放。 The server probably won't even have a monitor attached to it. 服务器可能甚至没有连接监视器。 Most likely, you'll get a whole series of exceptions from the video player telling you it couldn't initialize itself because there isn't any graphics environment in which to start. 最有可能的是,视频播放器会提供一系列异常,告诉您它无法初始化,因为没有任何可在其中启动的图形环境。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Tomcat中的Java应用程序? - Java application inside tomcat? Tomcat中出现NoClassDefFoundError,但动态创建的Java类的独立应用程序中没有 - NoClassDefFoundError in Tomcat but not in a Standalone application for a dynamically created java class Groovy Grails 独立应用程序,没有 tomcat 或任何其他 servlet 容器 - Groovy Grails standalone application without tomcat or any other servlet container 如何将 Spring-Boot-Webflux 应用程序部署到 Tomcat 独立服务器? - How to deploy a Spring-Boot-Webflux application to Tomcat standalone server? 无法在独立Tomcat 8.5上启动Spring Boot 1.5.1应用程序 - Unable to start Spring Boot 1.5.1 application on Standalone Tomcat 8.5 Spring Boot应用程序可以独立运行,但是在Tomcat中部署时找不到类 - Spring Boot application works as standalone but class not found when deployed in Tomcat Spring Boot应用程序在Intellij上启动,但在Tomcat独立服务器上无法启动[Gradle] - Spring Boot Application starts on Intellij but not on Tomcat standalone [Gradle] 应用程序的哪个DataSource在独立和webapp上下文(Java 7,Tomcat 7)中都使用了? - Which DataSource for application used both in standalone and webapp context (Java 7, Tomcat 7)? Tomcat JNDI +独立Java - Tomcat JNDI + Standalone Java Spring是独立的还是Tomcat? - Spring as standalone or on Tomcat?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM