Single console in eclipse for both Server and Client
Posted
by rits
on Stack Overflow
See other posts from Stack Overflow
or by rits
Published on 2010-04-25T09:17:10Z
Indexed on
2010/04/25
9:23 UTC
Read the original article
Hit count: 334
I am building a client server application using Java Sockets (in Windows XP). For that I need different consoles for both Client and Server(for Input and Output operations). But in eclipse both share a single console. Is there any plugin or some sort of cheat through which I can do this.
After googling I got this,
http://dev.eclipse.org/newslists/news.eclipse.newcomer/msg17138.html
But, this seems to be only for write operations, not read operations.
Also, I tried the following to launch application manually, but even this is not working........
package mypack;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
public class MySystem {
public static void changeStream(String mainFile) throws IOException{
File temp = new File(".") ;
String parentPath = temp.getCanonicalPath() ;
System.out.println(parentPath);
//creation of batch file starts here
try{
File f = new File(parentPath + "\\a.bat") ;
System.out.println("Created : " + f.createNewFile());
//f.deleteOnExit() ;
FileOutputStream fos = new FileOutputStream(f) ;
String str = "java " + mainFile ;
String batchCommand="@echo off\n"+str+"\npause\nexit";
char arr[] = batchCommand.toCharArray() ;
System.out.println(str) ;
for(int i = 0 ; i < arr.length ; i++){
fos.write(arr[i]) ;
}
fos.close() ;
}
catch(Exception e){
}
//creation of batch file ends here
//execution of batch file starts here
try{
Runtime r = Runtime.getRuntime() ;
System.out.println(parentPath + "\\a.bat") ;
Process p = r.exec(new String[]{"cmd","/k","start a.bat"},null,new File(parentPath)) ;
OutputStream os = (OutputStream)p.getOutputStream() ;
System.setOut( new PrintStream(os) ) ;
System.out.println("Hello");
}
catch(Exception e){
e.printStackTrace();
}
//execution of batch file ends here
}
public static void main(String[] args) throws IOException {
MySystem.changeStream("MySystem") ;
}
}
© Stack Overflow or respective owner