-1

我开发了简单的网络应用程序“myapplication”。我部署到 Tomcat 6.0.29 中。

应用程序停止,当我执行此“http://localhost:8080/manager/stop?path=/myapplication”

是否可以使用 java 程序启动应用程序?
是否可以使用 java 程序停止应用程序?

帮我。提前致谢。


不能在 Windows 中工作。它适用于linux ubuntu

使用时出现错误

Process p = r.exec("wget http://tomcatusername:tomcatepassword@localhost:8080/manager/stop?path=/myapplication -O - -q"); 

错误是:

Error occur: java.io.IOException: Cannot run program "wget": 
CreateProcess error=2, The Stystem cannot find the file specified  

任何人都可以帮助我。提前致谢。

4

2 回答 2

0

标准 java 网络库没有办法。

尝试使用库org.apache.httpcomponents.httpclient此代码适用于 Tomcat 7

HttpGet httpGet = new HttpGet("http://" + host + ":" + port + "/manager/text/" + action + "?path=/" + app);
        DefaultHttpClient httpClient = new DefaultHttpClient();

        httpClient.getCredentialsProvider().setCredentials(new AuthScope(host, Integer.valueOf(port)),
                new UsernamePasswordCredentials(username, password));
        HttpConnectionParams.setConnectionTimeout(httpClient.getParams(), 2000);
        HttpConnectionParams.setSoTimeout(httpClient.getParams(), 2000);
        HttpResponse response = httpClient.execute(httpGet);
于 2015-01-21T11:09:48.190 回答
0

尝试这个 :

Process p = r.exec("wget http://tomcatusername:tomcatepassword@localhost:8080/manager/stop?path=/myapplication -O - -q"); 
于 2012-12-18T07:28:49.697 回答