How to solve the 'could not find or load main class robocode.robocode' error?

1.2k Views Asked by At

I am now a starter in Robocode and now I am trying to run my first robot from Eclipse. I have followed the tutorial on Robocodewiki but the Eclipse keep reporting Error: Could not find or load main class robocode.Robocode Caused by: java.lang.ClassNotFoundException: robocode.Robocode

Here is my first robot code:

package robots;
import robocode.*;
//import robocode.Robocode;
//import robocode.ScannedRobotEvent;

public class Robot1 extends Robot {
public void run() {
    while (true) {
        ahead(100);
        turnGunRight(360);
        back(100);
        turnGunRight(360);
    }
}

public void onScannedRobot(ScannedRobotEvent e) {
    fire(1);
}

}

This project is stored at E:\Java Pojects\MyRobot while my robocode was installed at C:\robocode Also the JRE library JavaSE-11(jdk-11.0.1) and robocode version1.9.3.7

Appreciate if anyone can help me with this

1

There are 1 best solutions below

0
On

The problem was solved: When you import the external .jar file you should add it to your projects' classpath rather than the module path then this problem will be solved.