1:我记得<JAVA高级特性>2中有一篇讲过类似的问题.
2:可以,在csdn java区中搜一下.有解答.
3:不知是什么意思.能在讲清楚些吗?

解决方案 »

  1.   

    这是典型的网络程序设计,Java怎么可能作不到呢?
    你看一下http://www.java.sun.com/docs/books/tutorial/networking/sockets/index.html
    Java调用C/C++程序,可以用 Runtime.getRuntime().exec ("文件名")
    而且可以用JNI调用Win32的函数等等,还可以调用COM组件,但是这些就失去了Java的
    跨平台的特性!
      

  2.   


    很典型的嘛,建立Socket,建立IO流,就行了,别忘了多线程!
      

  3.   

    1和2都是JAVA的典型应用,我试过的!
    给你贴个很简单的C/S的例子启发一下你,希望对你有用。
    //================Server端=====================
    import java.net.*;
    import java.io.*;
    import java.util.*;public class javaserver extends Thread {
       protected ServerSocket server;
       
       public javaserver(){
        try{
           server = new ServerSocket(600);
          }catch(IOException e){
             System.out.println("Cannot create serversocket!Error is " + e);
             System.exit(0);
          }
        System.out.println("New serversocket is created!");
        this.start();
       }
      public void run() {
        try {
          while (true) {
           Socket client = server.accept();
           service ss = new service(client); 
          }
        }catch(IOException e){
          System.out.println("Cannot provide service!");
          System.exit(1);
        }
      } public static void main(String args[]) {
       String data;
       DataInputStream KeyInput;   
       
       new javaserver();
       KeyInput = new DataInputStream(System.in);
       try {
        data = KeyInput.readLine();
       }catch(IOException e)
        {
          return;
        }
      if (data.equals("quit")) System.exit(1); 
      } 
    }class service extends Thread {
      String data;
      DataInputStream InputS;
      PrintStream     OutputS;
      Socket          client;
      
      public service(Socket ClientSocket) {   client = ClientSocket;
       try {
           InputS  = new DataInputStream(client.getInputStream());
           OutputS = new PrintStream(client.getOutputStream());
       }catch(IOException e){
         System.out.println("Cannot connect server!");
         return;
       }   this.start();  }  public void run() {
       
       try {
         while (true) {
          data = InputS.readLine();
          if (data==null) break;
           else {
             OutputS.println(data);
             System.out.println("From client: " + data);
           } 
         } 
       }catch(IOException e) {
          System.out.println("Cannot read data");
       }
       try{
        client.close(); 
       }catch(IOException e) {
         System.out.println("Cannot close socket");
       }
      }

    //================Client端================
    import java.net.*;
    import java.io.*;
    import java.util.*;public class javaclient {
     
     public static void main(String args[]) {
      String data;
      Socket client;
      DataInputStream InputS;
      DataInputStream KeyS;
      PrintStream     OutputS;  int i = 0;
      try{
       client = new Socket("127.0.0.1",600);
       InputS = new DataInputStream(client.getInputStream());
       OutputS = new PrintStream(client.getOutputStream());
       KeyS = new DataInputStream(System.in); 
      }catch(IOException e) {
        System.out.println("Cannot Connect with server");
        return;
      }
      
      try {
       while(i<5) {
         data = KeyS.readLine();
         OutputS.println(data);
         System.out.println("Echo From server:" +  InputS.readLine());
         i++;
       }
      }catch(IOException e){
        System.out.println("IOException Happended");
      }
      
     try {
      System.out.println("Now will end this program");
      client.close();
      }catch(IOException e){
        System.out.println("System cannot close socket");
      }
     }
    }