Menu

Unable to create batch files on Windows for my battles

Help
Ioan Turcu
2020-03-24
2026-01-23
  • Ioan Turcu

    Ioan Turcu - 2020-03-24

    Hi, I have a problem with trying to create a batch file for my battles in Robocode.
    This is the code I am using:

    @rem set JAVA_HOME = C:\Program Files\AdoptOpenJDK\jdk-8.0.242.08-hotspot
    @rem set PATH=.;%JAVA_HOME%\bin;%PATH%

    javac -encoding UTF-8 -cp libs\robocode.jar;robots robots\eu\ase\jrobot*java
    java -Xmx512M -cp libs/robocode.jar -XX:+IgnoreUnrecognizedVMOptions "--add-opens=java.base/sun.net.www.protocol.jar=ALL-UNNAMED" "--add-opens=java.base/java.lang.reflect=ALL-UNNAMED" "--add-opens=java.desktop/javax.swing.text=ALL-UNNAMED" "--add-opens=java.desktop/sun.awt=ALL-UNNAMED" robocode.Robocode %* -battle battles\Assignment.battle
    @pause

    But it gives me the following errors

    javac: invalid flag: robots\eu\ase\jrobot*java
    Usage: javac <options>
    use -help for a list of possible options</options>

    C:\Users\Alex\Desktop>java -Xmx512M -cp libs/robocode.jar -XX:+IgnoreUnrecognizedVMOptions "--add-opens=java.base/sun.net.www.protocol.jar=ALL-UNNAMED" "--add-opens=java.base/java.lang.reflect=ALL-UNNAMED" "--add-opens=java.desktop/javax.swing.text=ALL-UNNAMED" "--add-opens=java.desktop/sun.awt=ALL-UNNAMED" robocode.Robocode -battle battles\Assignment.battle
    Error: Could not find or load main class robocode.Robocode

    I think the issue is coming from the first error, any ideas on how to fix it? Thanks in advance!
    Sent from Mail for Windows 10

     
  • Flemming N. Larsen

    Hi Ioan,

    You do not have to write all that stuff. Just use robocode.bat for specifying the battle like:

    robocode -battle intro
    

    All the ugly stuff has been put into the robocode.bat and robocode.sh so you don't have to be bothered with all the details for running robocode. :-)
    Notice the last argument in robocode.bat: %*

    The last part (%*) is used for specifying commands when using robocode.bat. ;-)

    So you should be able to run your battle by standing in the robocode home folder and write:

    robocode -battle Assignment
    

    I hope this helps?

     
  • scott danial

    scott danial - 2026-01-23

    The first error is caused by a typo in your javac command—you’re missing a dot before java in the wildcard. It should be robots\eu\ase\jrobot*.java, not *java. Once the classes compile correctly, also ensure your classpath includes both robocode.jar and the current directory (-cp .;libs\robocode.jar), otherwise Java won’t find robocode.Robocode.

     

Log in to post a comment.

MongoDB Logo MongoDB