title: MPJ Express Sending and Receiving - ClassCastException
body: <p>I've looked at this but it didn't reallly help as I'm dealing with primitives, not objects. This is just part of a extra section is a project. It's fine as it is, but I'd like to have it working.</p>
  
  <p>It's compiling fine, but when I run it, I get, at line 20, a ClassCastException. </p>
  
  <pre><code>/* Java Version (mine) */    
  public class PingPongJava { 
  
      public static void main(String args[]) throws Exception { 
          int me;
          int size;
          int recv_buf = 0;
          int buf = 0;
          int send_buf = 101;
          double tic = 0, toc = 0;
  
          MPI.Init(args);
          me = MPI.COMM_WORLD.Rank();
          size = MPI.COMM_WORLD.Size();
  
          tic = MPI.Wtime();
          for (int i = 0; i &lt; 50; i++){
              if (me == 0){
              MPI.COMM_WORLD.Send(send_buf, 0,1,MPI.INT, 17, 100);
              MPI.COMM_WORLD.Recv(recv_buf, 0,1, MPI.INT, 23, 100);
  
              }
              else{
              MPI.COMM_WORLD.Recv(buf, 0, 1, MPI.INT, 17, 100);
              MPI.COMM_WORLD.Send(buf, 0,1,MPI.INT, 23, 100);
              }
          }
          toc = MPI.Wtime();
          if (me == 0){
              System.out.println("Time taken is " + (toc-tic)/100);
              }
  
          MPI.Finalize(); 
       }
      } 
  </code></pre>
  
  <p>I'm converting from this C version</p>
  
  <pre><code>/* Point-to-point communication.
   */
  #include &lt;mpi.h&gt;
  #include &lt;stdio.h&gt;
  
  int main(int argc, char **argv){
    int rank, size, i, recv_buf, send_buf=101, buf;
    MPI_Status status;
    double tic, toc;
  
    MPI_Init(&amp;argc, &amp;argv);
    MPI_Comm_rank (MPI_COMM_WORLD, &amp;rank);
    MPI_Comm_size (MPI_COMM_WORLD, &amp;size);
  
    tic = MPI_Wtime();
    for(i=0;i&lt;50;i++){
      if(rank==0){
        MPI_Send(&amp;send_buf, 1, MPI_INT, 1, 17 , MPI_COMM_WORLD);
        MPI_Recv(&amp;recv_buf, 1, MPI_INT, 1, 23, MPI_COMM_WORLD, &amp;status);
      }else{
        MPI_Recv(&amp;buf, 1, MPI_INT, 0, 17, MPI_COMM_WORLD, &amp;status);
        MPI_Send(&amp;buf, 1, MPI_INT, 0, 23, MPI_COMM_WORLD);
      }
    }
    toc = MPI_Wtime();
  
    if(rank==0)
      printf("Average time for a single message: %lf seconds \n", (toc-tic)/100.0);
  
    MPI_Finalize();
    return 0;
  }
  </code></pre>