dcsimg
run batch or run java programme as a sub process
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   vinay_chandran
Posted On:   Friday, February 22, 2002 07:05 PM

i am having a menuitem that runs autoexec.bat through "Runtime.exec('start','c:autoexec.bat')" i have made a method that dose the processing of the process void process() { try{ InputStream is=p.getInputStream(); OutputStream os=p.getOutputStream(); InputStream es=p.getErrorStream(); BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(is)); { tb.setText(stringbuffera.toString()); } bufferedreader.close(); BufferedReader bufferedreader1 = new BufferedReader(new InputStreamReader(es)); while((s2 = bufferedreader1.readLine()) != null) { stringbuffer.append(s2+"   More>>


i am having a menuitem that runs autoexec.bat through

"Runtime.exec('start','c:autoexec.bat')"

i have made a method that dose the processing of the process

			


void process()
{
try{
InputStream is=p.getInputStream();
OutputStream os=p.getOutputStream();
InputStream es=p.getErrorStream();
BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(is));
{
tb.setText(stringbuffera.toString());
}
bufferedreader.close();
BufferedReader bufferedreader1 = new BufferedReader(new InputStreamReader(es));
while((s2 = bufferedreader1.readLine()) != null)
{
stringbuffer.append(s2+"
");
tb.setText(stringbuffer.toString()+"
");
//System.out.println("ERROR"+s2+"
");
}
bufferedreader1.close();
OutputStreamWriter oss=new OutputStreamWriter(os);
}catch(Exception q){tb.setText(" "+String.valueOf(q));System.out.println("the exception is "+q);}
}

this method wil do the errors and otherwise .

but if i have to open autoexec.bat than
then the porocessing should be in the doss panel
but it dose not happen like that . the code for this particular class is

			
public class autoexe implements ActionListener
{
public void actionPerformed(ActionEvent e)
{

try{

final Thread at=new Thread(new Runnable()
{
public void run()
{
try{

try{
String s[]={"start","c:/autoexec.bat"};
progress();
p=r.exec(s);
process();
p.waitFor();
ttt.join();
}catch(Exception re){System.out.println(re); JOptionPane.showMessageDialog(getContentPane(),"an exception occcured"+re.getMessage(),"EXCEPTION",JOptionPane.ERROR_MESSAGE); tb.setText(String.valueOf(re)); }
System.out.println(p.exitValue());
}catch(Exception o){System.out.println(o);tb.setText(String.valueOf(o));}
}
}
);
at.start();
ttt.sleep(500);//the thread with max-priority this thread is in the main
if(at.isAlive()==false){

at.destroy();
mainframe.addNotify();
}
}catch(Exception o){System.out.println(o);tb.setText(String.valueOf(o));}
}
}





same goes for the script that
what this dose is the opening of a java prog thrown in a new console


now my question s how do you throw the processing to the new panel    <<Less
About | Sitemap | Contact