I have the programming game 'Robocode' in my project root so I can run the project anywhere and not have it installed in C:/robocode. I have a run configuration with the following options;
- Main Class: robocode.Robocode
- VM Options: -Xmx512M -Dsun.io.useCanonCaches=false -Ddebug=true -DNOSECURITY=true -cp libs/robocode.jar
- Working directory: MY_ROOT\robocode_master
- JRE: Default(9.0.1 - SDK of my main module)
I'm writing some custom functionality for an AdvancedRobot that connects to a MongoDBAtlas Cluster for necessary data. I'm using mongo-java-driver-3.6.1. The .jar has been added as a library to IntelliJ, then as a compile dependency on the main module. It works fine in testing, I can download documents etc.
To illustrate, the libraries are shown here in the Project structure pane.
I have set the compile output path to the robocode_master/robots directory so that when I run Robocode from IntelliJ, it will see the custom robot .class files in the correct directory and allow me to add them to a battle.
The problem is when I start the battle and the robot tries to do what it needs to do, it throws a java.io.FileNotFoundException and is trying to find the necessary library files from the robocode_master/robots directory.
For example, the first thing it does is connect to the DB;
java.io.FileNotFoundException: MY_ROOT\robocode_master\robots\com\mongodb\MongoClient.class (The system cannot find the path specified)
When I have my project output paths set to the robots folder, upon launching Robocode, it throws a bunch of FileNotFoundExceptions. But if I switch the options to 'Inherit project compile output path', then launch Robocode, I don't get the exceptions upon launch. But now of course, my robots aren't in the default directory, so it can't see them. So I add the new path in out/production/... to Robocode in the GUI and reboot, and I then get the same exceptions from the robots. It now tries to look for the files in out/production/.../com/mongodb/MongoClient.class
How can I 'tell' Robocode to look for the libraries in their default location on the classpath?