title: Porting my existing java project on Netbeans to another machine and then running it gives a UnsupportedClassVersionError
body: <p>I started coding for a client-server machine on java, using RMI(Remote Method Invocation). The code works fine on my machine. It basically gives commands to the client machine and the client processes these commands and responds accordingly. After executing the command, the machine sends back its status to the server. An example would be, the server requests for an image feed from the client and the client returns an image to the server.</p>
  
  <p>I used git to clone the current project and push it to another machine. When I execute the client side code, it works completely fine and the other machine(to which I pushed the source) responds the way it should.</p>
  
  <p>However, when I run the server side code to code on the other machine, it gives a cryptic error that says:</p>
  
  <pre><code>C:\Users\RdX\Desktop\Thiswa
  javax.naming.NamingException [Root exception is java.rmi.ServerError: Error occurred in          server thread; nested exception is: 
  java.lang.UnsupportedClassVersionError: javadrone/Server (Unsupported major.minor   version 51.0)]
  at com.sun.jndi.rmi.registry.RegistryContext.rebind(RegistryContext.java:159)
  at com.sun.jndi.toolkit.url.GenericURLContext.rebind(GenericURLContext.java:249)
  at javax.naming.InitialContext.rebind(InitialContext.java:427)
  at javadrone.server.ServerImpl.&lt;init&gt;(ServerImpl.java:46)
  at javadrone.server.DroneServer.&lt;init&gt;(DroneServer.java:45)
  at javadrone.server.DroneServer.main(DroneServer.java:84)
  Caused by: java.rmi.ServerError: Error occurred in server thread; nested exception is: 
  java.lang.UnsupportedClassVersionError: javadrone/Server (Unsupported major.minor    version 51.0)
  at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:349)
  at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:207)
  at sun.rmi.transport.Transport$1.run(Transport.java:148)
  at java.security.AccessController.doPrivileged(Native Method)
  at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
  at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
  at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
  at java.lang.Thread.run(Thread.java:534)
  at     sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:273)
  at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:251)
  at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:377)
  at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
  at com.sun.jndi.rmi.registry.RegistryContext.rebind(RegistryContext.java:157)
  ...5 more
  </code></pre>
  
  <p>On inspecting the stack trace, the code that generates the exception is:</p>
  
  <pre><code>package javadrone.server;
  
  
  import javadrone.Drone;
  import javadrone.Server;
  
  import javadrone.command.CommandQueue;
  
  
  import java.rmi.RemoteException;
  import java.rmi.server.UnicastRemoteObject;
  
  import java.util.HashMap;
  
  import javax.naming.Context;
  import javax.naming.InitialContext;
  import javax.naming.NamingException;
  
  public abstract class ServerImpl extends UnicastRemoteObject implements Server {
  public static final String            RMI_PROT = "rmi:";
  private static Context                namingContext;
  private static HashMap&lt;String, Drone&gt; registeredDrones;
  private String                        name;
  
  public ServerImpl(String name) throws RemoteException, NamingException {
      this.name     = name;
      namingContext = new InitialContext();
      namingContext.rebind(RMI_PROT + name, ServerImpl.this);
      registeredDrones = new HashMap&lt;&gt;();
  }
  
  @Override
  public String getName() throws RemoteException {
      return name;
  }
  
  @Override
  public Drone registerDrone(String droneName) throws RemoteException {
      System.out.println("Remote client registered...");
  
      DroneImpl d = new DroneImpl(new CommandQueue(), droneName);
  
      registeredDrones.put(droneName, d);
      hasRegistered(d);
  
      return d;
  }
  
  public Drone getDrone(String droneName) {
      return registeredDrones.get(droneName);
  }
  
  @Override
  public long getTime() throws RemoteException {
      return System.currentTimeMillis();
  }
  
  public abstract void hasRegistered(DroneImpl d);
  }
  </code></pre>
  
  <p>To be specific, </p>
  
  <pre><code>namingContext.rebind(RMI_PROT + name, ServerImpl.this)
  </code></pre>
  
  <p>is the line that generates the error.</p>
  
  <p>I searched a lot of places and they say that when the JDK compliler is of a higher version than the JRE version, it may produce such an error.</p>
  
  <p>However I uninstalled all prior JDKs and JREs and recompiled the code after installing JDK 7.03. It still gives the same exception.</p>
  
  <p>Why is this happening and how do I correct it?</p>