Applications/processes 运行 在 Windows 上使用 Java 8 不可见

Applications/processes ran using Java 8 on Windows are not visible

这让我加班加点,到现在也没有太多线索。我有一个本地安装的 Web 应用程序(伪桌面应用程序),它执行以下操作:

  1. 启动 SSH 隧道
    • 直接 运行s ssh if on Mac OS X
    • 如果在 Windows
    • 上,则使用 PuTTy 可执行文件
  2. 打开 Firefox 或 Chrome 配置为通过 Selenium 网络驱动程序使用隧道 (localhost:port) 使用 Socks5 代理。

对于 1: Runtime.getRuntime().exec(command);Process proc = new ProcessBuilder(arguments).start(); 我都用过,甚至试过 Desktop dt = Desktop.getDesktop(); dt.open(f);。但是没有任何反应,没有命令提示符打开。

对于 2: 我试过同时使用 Firefox:

    FirefoxProfile profile = new FirefoxProfile();
    profile.setPreference("network.proxy.type", 1);
    profile.setPreference("network.proxy.socks", "localhost");
    profile.setPreference("network.proxy.socks_port", 8088);
    driver = new FirefoxDriver(profile);

和Chrome:

DesiredCapabilities capabilities = DesiredCapabilities.chrome();
    capabilities.setCapability("chrome.switches", Arrays.asList("--proxy-server=socks5://localhost:8088"));
    driver = new ChromeDriver(capabilities);

但是和1类似,没有firefox或者chrome windows打开。

请注意,此应用程序在 Mac OS X Mavericks 上完美运行。

经过几个小时的调试,我注意到进程在那里。所有进程,从 PuTTy,到 Chrome,再到 Firefox。背景中已经有很多 运行ning。奇怪的是,这些进程的用户列设置为SYSTEM,而正常的浏览器会话,例如用户设置为"IT",这是我当前的Windows用户帐户。

我一直在尝试手动更改调用这些进程的用户,但到目前为止没有成功。

很明显,我的应用程序也可以在 Windows 中运行,只是与我预期的不同。所有进程,无论是命令行脚本还是桌面应用程序,如 firefox 或 chrome,它们只是不出现,但它们 运行 在用户 "SYSTEM" 的后台。我不知道为什么。它看起来不像是默认行为。因此,如果有人有任何想法,我将不胜感激。

谢谢。

我终于解决了这个问题!感谢这个article(来自一个看似不相关的案例):

Most Windows services -- including those run with the option "Allow service to interact with desktop" in Windows XP and Vista -- do not have access to many of the computer's resources, including the console display. This may cause Automated GUI Tests to fail if you are running Apache Tomcat as a Windows Service and are doing any GUI testing. This is true at least for AWT and Abbot frameworks.

This limitation can be resolved by not running Tomcat as a Windows Service, but instead through a "Scheduled Task" as an Application that runs at logon. There are several options for doing this, an example would be to run "$TOMCAT_HOME\bin\tomcat5.exe". When setting up the scheduled task in Windows Vista consider choosing the check-box for "Run with highest privileges" from the general tab, as this removes the need to always provide administrator privileges and may resolve other issues as well.

我所做的不是 运行 tomcat7 作为 Windows 服务,而是直接执行 C:\Program Files\Apache Software Foundation\Tomcat 7.0\bin\Tomcat7.exe 并且一切正常。我可以简单地把它作为一个计划任务,这样它仍然可以自动启动(或者只是把它放在启动时)。