Single console in eclipse for both Server and Client
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") ;
}
}
Ok Guyz, previously I don't know that multiple consoles are available in eclipse. But now i got this from here, tht's why closing this thread. Cheers :)
I have only found that you can do that with separate launches in Eclipse (so you need to launch first your server, and then your client).
Unfortunately each Console is then a pane in the Console view, and not its own Console so you have to manually switch, but that is the best I've found so far.
精彩评论