java - 在tomcat上运行java应用程序

标签 java apache tomcat

我们如何在 apache tomcat 服务器上运行 java 应用程序?我试过编辑 xml 文件,还尝试制作一个 war 文件并将其放在 tomcats webapp 目录中。

方法测试和测试 2 是我制作的一个简单 Java 应用程序中的方法。 我有以下类(class)

@Path("/hello")
public class HelloWorldService {
    RemoteEV3 ev3;
    static RMIRegulatedMotor motorA;

    static boolean stop=false;

    @Path("{f}")
    @GET
    @Produces("application/json")
    public Response DeployRobot(@PathParam("f") String f) throws JSONException, NotBoundException, IOException {
        String r="run";
        if(f.equals(r)) {
            test();
        } else {    
            test2();
        }

        return Response.status(200).entity("").build();
    }

    public static void test() throws IOException, IOException, NotBoundException {

        RemoteEV3 ev3=new RemoteEV3("10.0.1.1");
        ev3.isLocal();

        // Open Ports
        ev3.getPort("A");

        //create motors

        if(motorA==null){motorA=ev3.createRegulatedMotor("A", 'L');}

        //move motors, grab,suppress
        while (!stop){
            motorA.forward();
            grab();
            motorA.stop(true);
            Sound.twoBeeps();
            stop=true;
            System.out.println("Robot is moving!");
        }

        if (stop){
            motorA.close();
        }
    }

    public static void test2(){
        System.out.println("|***                           Move Robot                                   ****|");
    }

    public static void grab(){
        try{
            Thread.sleep(5000);
        }
        catch(InterruptedException e){
            e.printStackTrace();
        }
    }   
}

最佳答案

要在 Apache tomcat 上运行应用程序,您可以转到:

http://localhost:8080/manager

并管理您的网络应用程序,部署它们并添加您的 .war 文件

关于java - 在tomcat上运行java应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34503797/

相关文章:

java - Hazelcast MapStore 配置读取 block 大小

apache - SSL 大于 40 位的电子商务应用程序的系统要求

performance - 标准的 Jira on Tomcat 安装可以承受多少负载?

java - 线程停放在 java.util.concurrent.ThreadPoolExecutor.getTask 的原因可能是什么

Java 包 com 和 org

apache - 更改 httpd.conf 后重新启动 httpd

html - 为什么我的网页不能显示背景音乐?

java - Java 应用程序的 Web 用户界面

java - SAX 解析异常 : Content is not allowed in prolog

java - rxJava 中的开销