Unhandled exception instantiating robot: No Robot Code

Hello again, I am a member of team 4528 and recently we ran into some issues with putting code into the roboRio. Since then we have called National Instruments and re-imaged the roboRio and re-installed the java 8 jdk. We initially thought that this would clear the roboRio and that it would work again since we heard that we may have caused the code to crash by building conflicting codes. However even after the wipe the following error appeared in the DriverStation logs:

ERROR Unhandled exception instantiating robot org.usfirst.frc.team4528.robot.Robot java.lang.ClassNotFoundException: org.usfirst.frc.team4528.robot.Robot at [java.net.URLClassLoader$1.run(URLClassLoader.java:372), java.net.URLClassLoader$1.run(URLClassLoader.java:361), java.security.AccessController.doPrivileged(Native Method), java.net.URLClassLoader.findClass(URLClassLoader.java:360), java.lang.ClassLoader.loadClass(ClassLoader.java:424), sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308), java.lang.ClassLoader.loadClass(ClassLoader.java:357), java.lang.Class.forName0(Native Method), java.lang.Class.forName(Class.java:259), edu.wpi.first.wpilibj.RobotBase.main(RobotBase.java:197)]

The eclipse compiler says that the build was successful, but then this message shows up in the eclipse compiler:

Buildfile: C:\Users\Developer\workspace\FRC2015\build.xml
Trying to override old definition of task classloader
clean:
   [delete] Deleting directory C:\Users\Developer\workspace\FRC2015\build
   [delete] Deleting directory C:\Users\Developer\workspace\FRC2015\dist
compile:
    [mkdir] Created dir: C:\Users\Developer\workspace\FRC2015\build
     [echo] [athena-compile] Compiling src with classpath=C:\Users\Developer/wpilib/java/current/lib/WPILib.jar:C:\Users\Developer/wpilib/java/current/lib/NetworkTables.jar to build
    [javac] Compiling 2 source files to C:\Users\Developer\workspace\FRC2015\build
jar:
     [echo] [athena-jar] Making jar dist/FRCUserProgram.jar.
    [mkdir] Created dir: C:\Users\Developer\workspace\FRC2015\dist
    [mkdir] Created dir: C:\Users\Developer\workspace\FRC2015\build\jars
     [echo] [athena-jar] Copying jars from C:\Users\Developer/wpilib/java/current/lib/WPILib.jar:C:\Users\Developer/wpilib/java/current/lib/NetworkTables.jar to build/jars.
     [copy] Copying 2 files to C:\Users\Developer\workspace\FRC2015\build\jars
      [jar] Building jar: C:\Users\Developer\workspace\FRC2015\dist\FRCUserProgram.jar
get-target-ip:
     [echo] Trying Target: roboRIO-4528.local
     [echo] roboRIO found via mDNS
dependencies:
     [echo] roboRIO image version validated
     [echo] Checking for JRE. If this fails install the JRE using these instructions: https://wpilib.screenstepslive.com/s/4485/m/13503/l/288822-installing-java-8-on-the-roborio-using-the-frc-roborio-java-installer-java-only
  [sshexec] Connecting to roboRIO-4528.local:22
  [sshexec] cmd : test -d /usr/local/frc/JRE
deploy:
     [echo] [athena-deploy] Copying code over.
      [scp] Connecting to roboRIO-4528.local:22
      [scp] done.
      [scp] Connecting to roboRIO-4528.local:22
      [scp] done.
     [echo] [athena-deploy] Starting program.
  [sshexec] Connecting to roboRIO-4528.local:22
  [sshexec] cmd : . /etc/profile.d/natinst-path.sh; /usr/local/frc/bin/frcKillRobot.sh -t -r;
  [sshexec] start-stop-daemon: warning: killing process 1470: No such process
BUILD SUCCESSFUL
Total time: 25 seconds

For those of you who are interested in our code these are the ones we used:
Note: we are using code that was previously functional.

package org.usfirst.frc.team4528.robot;


import edu.wpi.first.wpilibj.Joystick;

import edu.wpi.first.wpilibj.RobotDrive;

import edu.wpi.first.wpilibj.SampleRobot;

import edu.wpi.first.wpilibj.Victor;

import edu.wpi.first.wpilibj.Timer;

public class Robot15 extends SampleRobot {

			Victor frontLeft;
		
			Victor rearLeft;

			Victor frontRight;

			Victor rearRight;

			Victor motor;	//add-on
		
			RobotDrive myRobot;	// class that handles basic drive operations
	    
			XBoxJoystick gamepad;	// declare gamepad as a Joystick object to get Joystick functionality, but with different buttons

		public void Robot()
		{
	    	
			frontLeft = new Victor(9);	//change port to appropriate PWM port on roboRIO
	    	
			rearLeft = new Victor(8);	//change port to appropriate PWM port on roboRIO
	    	
			frontRight = new Victor(7);	//change port to appropriate PWM port on roboRIO
	    	
			rearRight = new Victor(6);	//change port to appropriate PWM port on roboRIO

			motor = new Victor(5);		//add-on
	        
			myRobot = new RobotDrive(frontLeft, rearLeft, frontRight, rearRight);	// robot drivetrain functionality; takes in front left motor, rear left motor, front right motor, rear right motor ports
	        
			gamepad = new XBoxJoystick(0);	// port gamepad is plugged into

	    	}

		//add-on
	    

		public void runMotor()
	    
		{

	        	if(gamepad.getLeftZ() > 0)

	        	{

	        		motor.set(gamepad.getLeftZ());

	        	}

	        	else if(gamepad.getRightZ() > 0)

	        	{

	        		motor.set(-gamepad.getRightZ());

	        	}

	        	else

	        	{

	        		motor.set(0.0);

	        	}
	    
		}

	//end of...
	    

	/**
	     
	 * Runs the motors with tank steering.
	     
	 */
	    
		public void operatorControl() 
		{

	        	myRobot.setSafetyEnabled(false);
	        
			while (isOperatorControl() && isEnabled()) 
			{

				//myRobot.tankDrive(gametpad.getLeftY(), gamepad.getRightY());
	        	
				myRobot.tankDrive(gamepad.getRightY(), gamepad.getLeftY());
	            
				Timer.delay(0.005);		// wait for a motor update time
				
				gamepad.getAButton();
	            
				runMotor();
	            
	        
			}
	    
		}


}

package org.usfirst.frc.team4528.robot;

import edu.wpi.first.wpilibj.Joystick;

public class XBoxJoystick {
    private Joystick joystick;
    private int port;

    private final double DEAD_ZONE = 0.08; // Chief Delphi said 0.05;

    public XBoxJoystick(int port) {
            this.port = port;
            this.joystick = new Joystick(port);
    }

    public double getLeftX() {
            return correctDeadSpot(joystick.getRawAxis(0));
    }

    public double getLeftY() {
            return correctDeadSpot(joystick.getRawAxis(1));
    }

    public double getLeftZ() {
        return joystick.getRawAxis(2);
    }
    
    public double getRightZ() 
    {
        return joystick.getRawAxis(3);
    }

    public double getRightX() {
            return correctDeadSpot(joystick.getRawAxis(4));
    }

    public double getRightY() {
            return correctDeadSpot(joystick.getRawAxis(5));
    }

    public double getDpadX() {
            return joystick.getRawAxis(6);
    }

    // WARNING this doesn't work with vanilla driver station
    public double getDpadY() {
            return joystick.getRawAxis(7);
    }

    public boolean getAButton() {
            return getButton(1);
    }

    public boolean getBButton() {
            return getButton(2);
    }

    public boolean getXButton() {
            return getButton(3);
    }

    public boolean getYButton() {
            return getButton(4);
    }

    public boolean getLBButton() {
            return getButton(5);
    }

    public boolean getRBButton() {
            return getButton(6);
    }

    public boolean getBackButton() {
            return getButton(7);
    }

    public boolean getStartButton() {
            return getButton(8);
    }

    public boolean getLSButton() {
            return getButton(9);
    }

    public boolean getRSButton() {
            return getButton(10);
    }

    private double correctDeadSpot(double value) {
            if (Math.abs(value) < DEAD_ZONE)
                    return 0;
            return value;
    }

    private boolean getButton(int buttonNumber) {
            return joystick.getRawButton(buttonNumber);
    }
}

I would really appreciate if someone could explain what I did wrong and how I can fix it. I tried looking at the RobotBase.class from wpilib but couldn’t really understand it, all I could gather was that the code allowed the program to compile despite some errors that normally would be caught by the compiler. Thanks in advance for the help and sorry for the long post :P.

Did you rename your main class after creating the project?

Yes, I did. I renamed it Robot15 from Robot.

Do you think that maybe by changing the main classes name the RobotBase.class can’t call it by name?

If you create a new project from the template, and deploy it to the robot, does it have the same behavior?

It should since the initial project was created by me as well. But that’s just my logic, I’m not 100% certain.

I also deleted the other templates so that they wouldn’t conflict with the current code, so there is only one project.

If you renamed the main project then you need to change the build settings since it’s still looking for your code in the Robot.java class

If you rename the Robot class, you need to change the settings in the build.properties file of your project.

Could you give the steps to doing this, I would really appreciate it. Thanks in advance.

Here is how to solve this issue:

Open Eclipse and in the package explorer on the left side of the screen, click the arrow next to the name of your project. Towards the bottom of the new entries, you should see a file called “build.properties”. Double click on that file to open it. Now, where it says “package=”, write the package that your main class is in after the “=”, and where it says “robot.class=${package}.Robot”, change whatever is after the “.” to what your main class is called. We had this exact same issue and these are the steps we took to solve it.

I had the same error for a while. If you find that the DS is telling you to look in RobotBase.java, then it is an error on your end. Try checking all pwm channels that you are using and maybe changing them out. I’m not sure if there is a specific reason why you are using higher numbered pwm channels. But, 0-3 should work perfectly.