我在Java中使用Runtime.getRuntime().exec()命令来启动批处理文件,该批处理文件又启动Windows平台的另一个进程.
javaw.exe(Process1)
|___xyz.bat(Process2)
|___javaw.exe(Process3)
Run Code Online (Sandbox Code Playgroud)
Runtime.getRuntime().exec()返回一个具有destroy方法的Process对象,但是当我使用destroy()时,它只会杀死xyz.bat并使批处理文件的子进程悬空.
Java中是否有一种干净的方法来破坏以批处理为根的进程树?
*我不能使用任何自定义库\摆脱批处理文件以绕过问题
我使用selenium-2.30.0运行一个测试(在Windows上),运行了几个小时(~8小时).我使用的是FF驱动程序,但是在45分钟或更短的时间后内存耗尽,测试执行就会挂起.我无法使用HTMLUnitDriver(我认为纯Java解决方案是答案)以与FF驱动程序相同的方式运行(因为它需要等待页面加载而且我绝对不想在我的代码中放置随机线程睡眠或通过扩展HTMLUnitDriver实现任何新功能.
有没有办法让这个工作?
testing performance selenium webautomation selenium-webdriver
我正在尝试创建一个按钮面板,其中单击的按钮变为"不同颜色"; 即显示背景图像.ps我只需要这种方法(有2张图片),而不是其他任何东西.谢谢 !
例如:
public class TestPane extends JPanel {
private BufferedImage imgUnclicked;
private BufferedImage imgClicked;
private Point mousePoint;
public TestPane() {
try {
imgUnclicked = ImageIO.read(new File("C:\\Users\\Me\\Desktop\\tmp\\Uncolored.png"));
imgClicked = ImageIO.read(new File("C:\\Users\\Me\\Desktop\\tmp\\Colored.png"));
} catch (IOException ex) {
Logger.getLogger(Spotlight.class.getName()).log(Level.SEVERE, null, ex);
}
addMouseMotionListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
mousePoint = e.getPoint();
repaint();
}
});
}
}
@Override
protected void paintComponent(Graphics g) {
//Draw imgClicked
//Draw imgUnclicked with some rectangular area around mouse click subtracted
}
}
Run Code Online (Sandbox Code Playgroud) java ×2
batch-file ×1
cmd ×1
image ×1
performance ×1
process ×1
selenium ×1
swing ×1
testing ×1
windows ×1