2014-11-30 3 views
0

자바 네트워킹을 통해 행렬 곱셈 데모를 실행하는 프로젝트가 있습니다.Eclipse에서 "오류 : 기본 클래스 Coordinator.java를 찾거나로드 할 수 없습니다"라는 오류 메시지가 나타납니다.

'Error: Could not find or load main class Coordinator.java' 

하지만 를 실행하고 클래스가 수행은 주요 방법이있다 : 이클립스 실행할 때

나는 다음과 같은 오류를 얻고있다. 나는 이것으로 무슨 일이 일어나고 있는지 잘 모르겠습니다. 나는 그것이 가장 가능성이 일식/구성 오류의 실현, 어쨌든 나는 그것을 전부의 Worker.java 및 DataIO.java 코드 아래 여기에 포함 http://i.imgur.com/uMoUcmp.png

:

나는 여기에 내가 있었다 이클립스 화면의 스크린 샷을 포함 5 클래스이고, 나머지 3은 jsfiddle에 넣습니다. Java가 아니더라도 (MatrixMultiple.java Connection.java Coordinator.java DataIO.java 및 Worker.java - Coordinator.java는 java 코드를 실행합니다.)

package socket_example_1row; 

import java.io.*; 
import java.util.Scanner; 

import java.net.InetAddress; 
import java.util.Arrays; 

import matrix.*; 

public class Worker { 

    int nodeNum; 
    int localPort; 
    Connection conn; 
    int dim; 
    int width; 
    int[][] a; 
    int[][] b; 
    int[][] c; 
    DataInputStream disCoor; 
    DataOutputStream dosCoor; 
    DataOutputStream dosLeft; 
    DataInputStream disRight; 

    public Worker(int nodeNum, int localPort) { 
     this.nodeNum = nodeNum; 
     this.localPort = localPort; 
    } 

    void configurate(String coorIP, int coorPort) { 
     try { 
      conn = new Connection(localPort); 
      DataIO dio = conn.connectIO(coorIP, coorPort); 
      dosCoor = dio.getDos(); 
      dosCoor.writeInt(nodeNum); 
      dosCoor.writeUTF(InetAddress.getLocalHost().getHostAddress()); 
      dosCoor.writeInt(localPort); 
      disCoor = dio.getDis(); 
      dim = disCoor.readInt();    //get matrix dimension from coordinator 
      width = disCoor.readInt(); 
      a = new int[dim][width]; 
      b = new int[dim][width]; 
      c = new int[dim][width]; 
      String ipLeft = disCoor.readUTF();  //left block connection info 
      int portLeft = disCoor.readInt(); 
      String ipRight = disCoor.readUTF();  //right block connection info 
      int portRight = disCoor.readInt(); 
      if (nodeNum%2==0) {  // Even # worker connecting manner 
       dosLeft = conn.connect2write(ipLeft, portLeft); 
       disRight = conn.accept2read(); 
      } else {    // Odd # worker connecting manner 
       disRight = conn.accept2read(); 
       dosLeft = conn.connect2write(ipRight, portRight); 
      } 
     } catch (IOException ioe) { 
      ioe.printStackTrace(); 
     } 
     System.out.println("Configuration done."); 
    } 

    // shift matrix a toward left, even # worker send before receive 
    void shiftLeftSend1st(int[][] mat, DataOutputStream dosL, DataInputStream disR) { 
     // send leftmost column 
     for (int i = 0; i < dim; i++) { 
      try { 
       dosLeft.writeInt(mat[i][0]); 
      } catch (IOException ioe) { 
       System.out.println("error in sending to left, row=" + i); 
       ioe.printStackTrace(); 
      } 
     } 
     // local shift 
     for (int i = 0; i < dim; i++) { 
      for (int j = 1; j < width; j++) { 
       mat[i][j - 1] = mat[i][j]; 
      } 
     } 
     // receive the rightmost column 
     for (int i = 0; i < dim; i++) { 
      try { 
       mat[i][width - 1] = disRight.readInt(); 
      } catch (IOException ioe) { 
       System.out.println("error in receiving from right, row=" + i); 
       ioe.printStackTrace(); 
      } 
     } 
    } 

    // shift matrix a toward left, odd # worker receive before send 
    void shiftLeftReceive1st(int[][] mat, DataOutputStream dosL, DataInputStream disR) { 
     int[] tempIn = new int[dim]; 
     int[] tempOut = new int[dim]; 
     for (int i = 0; i < dim; i++) { // receive a column from right 
      try { 
       tempIn[i] = disRight.readInt(); 
      } catch (IOException ioe) { 
       System.out.println("error in receiving from right, row=" + i); 
       ioe.printStackTrace(); 
      } 
     } 
     for (int i = 0; i < dim; i++) { // local shift 
      tempOut[i] = a[i][0]; 
     } 
     for (int i = 0; i < dim; i++) { 
      for (int j = 1; j < width; j++) { 
       a[i][j - 1] = a[i][j]; 
      } 
     } 
     for (int i = 0; i < dim; i++) { 
      a[i][width - 1] = tempIn[i]; 
     } 
     for (int i = 0; i < dim; i++) { // send leftmost column to left node 
      try { 
       dosLeft.writeInt(tempOut[i]); 
      } catch (IOException ioe) { 
       System.out.println("error in sending left, row=" + i); 
       ioe.printStackTrace(); 
      } 
     } 
    } 

    // shift matrix upward 
    void shiftUp(int[][] mat) { 
     // copy top row 
     int[] tempTop = new int[mat[0].length]; 
     for (int j = 0; j < tempTop.length; j++) { 
      tempTop[j] = mat[0][j]; 
     } 
     // local shift 
     for (int i = 0; i < mat.length-1; i++) { 
      for (int j = 0; j < mat[0].length; j++) { 
       mat[i][j] = mat[i+1][j]; 
      } 
     } 
     for (int j = 0; j < tempTop.length; j++) { 
      mat[mat.length-1][j] = tempTop[j]; 
     } 
    } 

    void compute() { 
     // get the block of a from coordinator 
     for (int i = 0; i < dim; i++) { 
      for (int j = 0; j <width; j++) { 
       try { 
        a[i][j] = disCoor.readInt(); 
       } catch (IOException ioe) { 
        System.out.println("error: matrix a " + i + ", " + j); 
        ioe.printStackTrace(); 
       } 
      } 
     } 
     MatrixMultiple.displayMatrix(a); 
     // get the block of b from coordinator 
     for (int i = 0; i < dim; i++) { 
      for (int j = 0; j <width; j++) { 
       try { 
        b[i][j] = disCoor.readInt(); 
       } catch (IOException ioe) { 
        System.out.println("error: matrix b " + i + ", " + j); 
        ioe.printStackTrace(); 
       } 
      } 
     } 
     MatrixMultiple.displayMatrix(b); 
     c = new int[a.length][a[0].length]; 
     for (int i=0; i < a.length; i++) { 
      Arrays.fill(c[i], 0); 
     } 
     // multiplication 
     for (int r = 0; r < a.length; r++) { 
      // computer one term in c 
      for (int i = 0; i < a.length; i++) { 
       for (int j = 0; j <a[0].length; j++) { 
        c[i][j] = c[i][j] + a[i][j] * b[i][j]; 
       } 
      } 
      System.out.println("Matrix c"); 
      MatrixMultiple.displayMatrix(c, 8); 
      // shift matrix a toward left 
      if (nodeNum%2==0) {   // Even # worker shifting procedure 
       shiftLeftSend1st(a, dosLeft, disRight); 
      } else {     // Odd # worker shifting procedure 
       shiftLeftReceive1st(a, dosLeft, disRight); 
      } 
      shiftUp(b); 
      System.out.println("Shifted matrix a, r=" + r); 
      MatrixMultiple.displayMatrix(a); 
      System.out.println("Shifted matrix b"); 
      MatrixMultiple.displayMatrix(b); 
     } 
     System.out.println("Matrix c"); 
     MatrixMultiple.displayMatrix(c, 8); 

    } 

    public static void main(String[] args) { 
     if (args.length != 4) { 
      System.out.println("usage: java Worker workerID worker-port-num coordinator-ip coordinator-port-num"); 
     } 
     int workerID = Integer.parseInt(args[0]); 
     int portNum = Integer.parseInt(args[1]); 
     Worker worker = new Worker(workerID, portNum); 
     worker.configurate(args[2], Integer.parseInt(args[3])); 
     worker.compute(); 
     try { 
      Thread.sleep(6000); 
     } catch (Exception e) { 
      e.printStackTrace(); 
     } 
     System.out.println("Press the enter key to exit."); 
     try { 
      new BufferedReader(new InputStreamReader(System.in)).readLine(); 
     } catch (IOException ioe) {ioe.printStackTrace();} 
    } 
} 

DataIO.java

package socket_example_1row; 

import java.io.*; 

public class DataIO { 
    DataInputStream dis; 
    DataOutputStream dos; 

    public DataIO(DataInputStream dis, DataOutputStream dos) { 
     this.dis = dis; 
     this.dos = dos; 
    } 

    public DataInputStream getDis() { 
     return dis; 
    } 

    public void setDis(DataInputStream dis) { 
     this.dis = dis; 
    } 

    public DataOutputStream getDos() { 
     return dos; 
    } 

    public void setDos(DataOutputStream dos) { 
     this.dos = dos; 
    } 
} 

나머지 Java 코드는 jsfiddle = Coordinator.java; MatrixMultiple.java; Connection.java : 너무 많은

http://jsfiddle.net/31y0ehep/

감사

+1

실행 구성에서 주 클래스 Coordinator.java가 될 수 있습니까? 그것은 socket_example_1row.Coordinator-Btw가되어야하며, System.out 사용법을 고칠 수도 있습니다. – Michal

+1

실행 구성에는 찾아보기 단추도 있습니다. 타격을 가하면 일식이 주를 이룰 수있는 클래스를 파악하고 선택할 수 있으므로 오타가있는 곳을 최소화하고 다른 오류를 최소화 할 수 있습니다. 이클립스가 당신에게 자바 프로젝트가 아니라 다음 프로젝트를 ist 브라우징 때 수업을 제공합니다. – Michal

+0

나는 그것을 chekcing 해요 – Coffee

답변

0

난 당신이 또한 작업자 클래스의 주요 방법을 왜 정말 말할 수 없다, 그러나 이클립스 관련 오류가 아닙니다 확인 다음을 시도하십시오.

  1. 프로젝트를 마우스 오른쪽 단추로 클릭하십시오.

  2. 실행시 실행 구성으로 이동하십시오.

  3. 프로젝트와 관련된 모든 실행 구성을 삭제하십시오.

+0

흠, 그래서'Run Configurations' 화면에 들어갔다. 어떤 이유로 든 clipse가 나에게 달려있다. 약 10 개의 구성 중 하나만 삭제할 수있었습니다. –

관련 문제