Runtime.getruntime 没有打开 notepad.exe 有什么问题 [英] What is Problem in Runtime.getruntime which does not open notepad.exe

查看:38
本文介绍了Runtime.getruntime 没有打开 notepad.exe 有什么问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当尝试执行包含以下代码的 servlet 时

when try to execute the servlet containing following code

Runtime rt = Runtime.getRuntime();
Process p = rt.exec("notepad.exe");

它不会在 windows server 2003 和 Tomcat 5 环境中启动应用程序但是在windows任务管理器中正在创建一个进程作为notepad.exe.

It doesn't launch the application in the environment windows server 2003 and Tomcat 5 but a process is being created as notepad.exe in the windows task manager.

在 windows xp 和 tomcat 6 环境下启动记事本

In windows xp and tomcat 6 environment launches the notepad

我需要在 windows server 2003 和 tomcat 5 上工作

i need to work on the windows server 2003 and tomcat 5

提前致谢

推荐答案

换句话说,它在您的本地开发机器(WinXP + Tomcat6)上启动,但不在生产/测试服务器上(Win2K3 + Tomcat5)?

In other words, it get launched on your local development machine (WinXP + Tomcat6), but not at a production/test server (Win2K3 + Tomcat5)?

您是否意识到 Java Servlet 代码在 服务器 机器上运行,而不是在 客户端 机器上运行,这在现实世界中通常是两个物理不同em> 机器通过网络连接?记事本在服务器机器(运行 web 服务器(Tomcat)的地方)打开,而不是在客户端机器(运行 webbrowser 的地方)打开.它适用于本地开发环境只是因为网络服务器和网络浏览器都在物理同一台机器上运行.

Do you realize that Java Servlet code runs at the server machine, not at the client machine, which are in real world usually two physically different machines connected by a network? The notepad is opened at the server machine (there where the webserver (Tomcat) runs), not at the client machine (there where the webbrowser runs). That it works at local development environment is just because both the webserver and webbrowser runs at the physically same machine.

登录到您的 Win2K3 环境,您会看到记事本在那里打开.

Login to your Win2K3 environment and you'll see that notepad is opened there.

如果您真的打算使用 Runtime#exec() 在客户端机器上启动 notepad.exe(我没有看到任何商业原因,但是除了),那么您需要为客户端提供一个具有 AppletWeb Start 应用程序 由 HTML/JSP 页面提供服务.这将被下载到客户端机器并在那里执行.

If you really intend to launch notepad.exe at the client machine using Runtime#exec() (I don't see any business reasons for this, but that aside), then you'll need to provide the client a Java application in flavor of an Applet or Web Start Application served by a HTML/JSP page. This will get downloaded to the client machine and will be executed there.

这篇关于Runtime.getruntime 没有打开 notepad.exe 有什么问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆