getRuntime().exec()问题-启动程序时如何显示出界面
写了一个简单的bean,功能是开启一个服务器的应用程序(比如media play),在jsp页面中被调用。现在的问题是,大多数应用可以启动,在任务管理器中可以找到,但没有用户界面,只是在后台开着,显示不出来。请问如何能在打开应用的同时显示出程序界面???
//bean程序 StartProcess.java
package startBean;
import java.util.*;
public class StartProcess
{
public StartProcess()
{
}
public static void startProcess(String command)
{
Runtime r = Runtime.getRuntime();
Process p = null;
try
{
p = r.exec(command);
}
catch(Throwable t)
{
t.printStackTrace();
}
}
public static void main(String[] args)
{
startProcess( "C:\\Program Files\\Windows Media Player\\wmplayer.exe ");
}
}
//jsp
<jsp:useBean id= "Start " class= "startBean.StartProcess "/>
String command = "C:\\Program Files\\Windows Media Player\\wmplayer.exe ";
Start.startProcess(command);
另外,如果直接运行我写的bean,就可以开启程序,并显示用户界面。
------解决方案--------------------55555555555555
才15分哦
bean
/**
*
*/
package com.ecc.test;
public class StartProcess {
private String command = "C:\\Program Files\\Windows Media Player\\wmplayer.exe ";
public String getCommand() {
return command;
}
public void setCommand(String command) {
this.command = command;
}
public void startProcess() {
Runtime r = Runtime.getRuntime();
Process p = null;
try {
p = r.exec(command);
} catch (Throwable t) {
t.printStackTrace();
}
}
public static void main(String[] args) {
new StartProcess().startProcess();
}
}
jsp
<%@ page language= "java " pageEncoding= "GBK "%>
<%@ taglib uri= "http://jakarta.apache.org/struts/tags-bean "
prefix= "bean "%>
<%@ taglib uri= "http://jakarta.apache.org/struts/tags-html "
prefix= "html "%>
<jsp:useBean id= "startPrograme " class= "com.ecc.test.StartProcess " scope= "page "> </jsp:useBean>
<%startPrograme.setCommand( "C:\\Program Files\\Windows Media Player\\wmplayer.exe ");
startPrograme.startProcess();
%>
<html>
<head>
<title> </title>
</head>
<body>