Robocode crashing at intialization

768 views
Skip to first unread message

John Davis

unread,
Apr 5, 2022, 1:58:02 PM4/5/22
to Robocode
Hi
can anyone help me please? I'm trying to setup a basic robot in Robocode for a college assignment. I did a basic program in eclipse, and set Robocode to initialize from there. Robocode starts up and then crashes. Has anyone every seen this? Please Please Help....Thanks

See the fault below from the console.....

Loaded net.sf.robocode.api
Loaded net.sf.robocode.core
Loading plugins from C:\robocode\libs
Loaded net.sf.robocode.battle
Loaded net.sf.robocode.host
Loaded net.sf.robocode.repository
Loaded net.sf.robocode.sound
Loaded net.sf.robocode.ui
Loaded net.sf.robocode.ui.editor
No robocode.properties. Using defaults.
No robocode.properties. Using defaults.
WARNING: A terminally deprecated method in java.lang.System has been called
WARNING: System::setSecurityManager has been called by net.sf.robocode.host.security.RobocodeSecurityManager (file:/C:/robocode/libs/robocode.host-1.9.4.5.jar)
WARNING: Please consider reporting this to the maintainers of net.sf.robocode.host.security.RobocodeSecurityManager
WARNING: System::setSecurityManager will be removed in a future release
java.lang.ExceptionInInitializerError
    at net.sf.robocode.repository.RepositoryManager.reload(RepositoryManager.java:164)
    at net.sf.robocode.ui.WindowManager.showSplashScreen(WindowManager.java:358)
    at net.sf.robocode.core.RobocodeMain.run(RobocodeMain.java:124)
    at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private static final java.util.HashMap sun.net.www.protocol.jar.JarFileFactory.fileCache accessible: module java.base does not "opens sun.net.www.protocol.jar" to unnamed module @529abded
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
    at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:178)
    at java.base/java.lang.reflect.Field.setAccessible(Field.java:172)
    at net.sf.robocode.io.URLJarCollector.<clinit>(URLJarCollector.java:48)
    ... 4 more

java.lang.ExceptionInInitializerError
    at net.sf.robocode.repository.RepositoryManager.reload(RepositoryManager.java:164)
    at net.sf.robocode.ui.WindowManager.showSplashScreen(WindowManager.java:358)
    at net.sf.robocode.core.RobocodeMain.run(RobocodeMain.java:124)
    at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private static final java.util.HashMap sun.net.www.protocol.jar.JarFileFactory.fileCache accessible: module java.base does not "opens sun.net.www.protocol.jar" to unnamed module @529abded
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
    at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:178)
    at java.base/java.lang.reflect.Field.setAccessible(Field.java:172)
    at net.sf.robocode.io.URLJarCollector.<clinit>(URLJarCollector.java:48)
    ... 4 more

fnl

unread,
Apr 5, 2022, 2:00:32 PM4/5/22
to Robocode

It seems to be a problem with the Java version.
I have tested Robocode against Java 17 with Eclipse Adoptium (Temurin) on Windows 11, where it seems to run.

I suggest you try to use an older Java version when running Robocode, e.g. version 11.

Which version of Java are you running? You can find out by writting this command from the command line:

java -version

Best regards,

- Flemming

Alessandro

unread,
Oct 3, 2022, 4:38:57 PM10/3/22
to Robocode
Hello Flemming,

Just had the same issue now on Ubuntu20.04 using jdk-17.0.4.1+1 from https://adoptium.net/temurin/releases/ (amongst others). I am sill a bit confused between Gradle, Jetbrains and OS configuration of the JDKs, however I thinks that is what I configured. In the end to get the test (mostly) running I had to use the VM option "--add-opens=java.base/java.util=ALL-UNNAMED" as described in https://github.com/junit-pioneer/junit-pioneer/issues/509. Although this has nothing to do with robocode, that helped.

BR
Alessandro

fnl

unread,
Oct 6, 2022, 9:21:24 AM10/6/22
to Robocode
Thank you for the follow-up. 🙂👍
 I will keep this in mind if we see this issue again, which is very likely.

Cheers,
- Flemming

heromoga2000

unread,
Nov 5, 2022, 4:50:25 AM11/5/22
to Robocode
i tried all java version still have this issue. any solution

heromoga2000

unread,
Nov 5, 2022, 4:50:40 AM11/5/22
to Robocode
please i have this issue any solution ????

On Thursday, October 6, 2022 at 6:21:24 AM UTC-7 fnl wrote:
Message has been deleted

fnl

unread,
Nov 5, 2022, 5:06:30 AM11/5/22
to Robocode
Hello everybody,

Newer versions of Robocode has issues with running with Java 12 or newer unless this option is being used: -Djava.security.manager=allow
Robocode make use of the Security Manager in Java, which is now deprecated for removal. Hence, setting the java.security.manager to allow will make sure the Security Manager can still be used.
At least until it will be completely removed from Java. Unfortunately, it is not simple to remove the security manager of Robocode, as it require a redesign and refactoring of the core of the game.

The newest versions of Robocode comes with robocode.cmd for Windows, robocode.sh for Linux/macOS, and robocode.command for older Macs. Within these files, there is two sets of command lines for starting Robocode. One of them is uncommented for older Java versions (prior to Java 12). So please remove the '#' mark from the first line with java -Xmx512M if you are using an old version of  and Java, and comment out the other one.

pwd=`pwd`
cd "${0%/*}"
# Older than Java 12
# java -Xmx512M -cp "libs/*" -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 $*

# Java 12 and newer
java -Xmx512M -cp "libs/*" -Djava.security.manager=allow -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 $*
cd "${pwd}"
Reply all
Reply to author
Forward
0 new messages