我的WebApplication中运行.exe程序有奇怪的问题。它在控制台模式下工作正常。Runtime.exec()在tomcat/web应用程序上无法正常工作
我的EXE应用程序代码:
...
Console.WriteLine("before getEnvirement");
IDictionary environmentVariables = Environment.GetEnvironmentVariables();
foreach (DictionaryEntry de in environmentVariables)
{
Console.WriteLine(" {0} = {1}", de.Key, de.Value);
}
Console.WriteLine("before new Application");
this.application = new App();
Console.WriteLine("after new Application");
...
其中,app()是COM库类(我说当然是参考)。
我的Java控制台/ WebApplication的代码:
before getEnvirement
<all my envirements>
before new Application
after new Application
在 “Web应用模式”(坏)输出:
before getEnvirement
Path = C:\Windows\system32; <...>
TEMP = C:\Windows\TEMP
在 “控制台模式”(正确)
try {
String[] callAndArgs = {"C:\\temp\\program.exe", "arg1", "arg2"};
Process p = Runtime.getRuntime().exec(callAndArgs);
p.waitFor();
} catch (IOException e) {
System.out.println("IOException Error: " + e.getMessage());
} catch (Exception e) {
System.out.println("Exception: " + e.getMessage());
}
输出
或者当我删除getEnvirement代码(也是坏的):
before getEnvirement
before new Application
EXE应用程序将不会关闭本身在Tomcat(我必须使用任务管理器杀吧)
而且我的问题:为什么不到风度工作在Tomcat是否正确?为什么exe程序在使用tomcat运行时遇到系统环境问题?最后:为什么它在控制台模式下工作? :)