[英]run java applications on tomcat
how can we run java applications on apache tomcat server? 我们如何在Tomcat服务器上运行Java应用程序? i have tried editing the xml file and also tried making a war file and placing it in tomcats webapp dir.
我尝试编辑xml文件,还尝试制作war文件并将其放置在tomcats webapp目录中。
the methods test and test 2 are methods from a simple java application i made. test和test 2方法是我编写的简单Java应用程序中的方法。 I have the following 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();
}
}
}
To run applications on Apache tomcat u can go to: 要在Apache tomcat上运行应用程序,您可以转到:
http://localhost:8080/manager
and manage your webapps, deploying them adding your .war file 并管理您的Web应用程序,进行部署并添加.war文件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.