error: could not find or load main class robocode.robocode
I am getting this error when I try to open robocode.bat. I checked java installation, it is working fine. I verified it with the website for verifying java installation.
I edited the environment variable. (Before doing this I was getting another error 'java' is unrecognised cmdlet' which was solved after I did this step).
What may have gone wrong? MY OS:- windows 8. I am installing 1.9 for .net robocode
Anonymous
Check that the content of your robocode.bat is something like this:
java -Xmx512M -cp libs/robocode.jar robocode.Robocode %*
Perhaps you have written 'robocode.robocode' instead of 'robocode.Robocode'. It must be a big capital letter 'R' for Robocode after the dot. :-)
Hello i'm FreeBSD maintainer for Robocode
http://www.freshports.org/games/robocode/
With new version robocode-1.9.0.0 get
robocode
java.lang.ClassNotFoundException: net.sf.robocode.core.RobocodeMainBase
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at net.sf.robocode.security.HiddenAccess.init(HiddenAccess.java:86)
at net.sf.robocode.security.HiddenAccess.robocodeMain(HiddenAccess.java:277)
at robocode.Robocode.main(Robocode.java:27)
I use this in FreeBSD to start Robocode to 1.8.3.0 have all good worked
cat files/robocode-sh.in
!/bin/sh
$FreeBSD: head/games/robocode/files/robocode-sh.in 329983 2013-10-10 12:10:24Z nemysis $
export JAVA_VERSION="%%JAVA_VERSION%%"
cd "%%DATADIR%%" && exec "%%LOCALBASE%%/bin/java" -Djava.ext.dirs="%%DATADIR%%" \ -Djava.ext.dirs="%%DATADIR%%" -cp libs/robocode.jar robocode.Robocode "${@}"
pkg info | grep java
aoi-3.0 Open source Java written 3D modelling and rendering studio
apache-ant-1.9.3 Java- and XML-based build tool, conceptually similar to make
bootstrap-openjdk-r347418 Oracle's Java 6 virtual machine release under the GPL v2
gcc-ecj-4.5 Eclipse Java Compiler used to build GCC Java
gjs-1.34.0 GNOME Javascript binding
java-zoneinfo-2013.i Updated Java timezone definitions
javavmwrapper-2.4_3 Wrapper script for various Java Virtual Machines
jogl-1.1.1_1 Java bindings for OpenGL
json-c-0.11 JSON (JavaScript Object Notation) implementation in C
linux-sun-jre17-7.51 Oracle Java 7 Runtime Environment for Linux
openjdk-7.51.13_2,1 Java Development Kit 7
robocode-1.9.0.0 Game for learning Java[tm] programming language
spidermonkey185-1.8.5_2 Standalone JavaScript (1.8.5) interpreter from Mozilla
This is strange to me as well as version 1.9.0.0 is "only" introducing a new robot type and fixes some bugs on the UI. Everything else has not been touched.
The error "java.lang.ClassNotFoundException: net.sf.robocode.core.RobocodeMainBase" is caused by Java, which cannot locate the libs/robocode.jar file, and hence not start up Robocode by invoking the RobocodeMainBase. Perhaps the working directory is changed. Robocode expects the working directory to be at the installation directory of Robocode. That is the same dir where the robocode.sh file is placed.
I wonder if Robocode starts up if you call ./robocode.sh when standing in the Robocode directory? If so, something is from with the robocode-sh.in version of the robocode.sh file.
It might also be caused by changes made to FreeBSD and/or Java since version 1.8.3.0 of Robocode? But I am only guessing.
I will need to download and install FreeBSD on my local machine to reproduce the issue.
Yes i have to this tried with all normal scripts, not works
FreeBSD files/robocode-sh.in have not changed from 1.8.3.0 and have good worked.
cd /usr/local/share/java/robocode/
./robocode.sh
Exception in thread "main" java.lang.NoClassDefFoundError: robocode/Robocode
Caused by: java.lang.ClassNotFoundException: robocode.Robocode
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
Could not find the main class: robocode.Robocode. Program will exit.
Similar get with
./meleerumble.sh
Exception in thread "main" java.lang.NoClassDefFoundError: roborumble/RoboRumbleAtHome
Caused by: java.lang.ClassNotFoundException: roborumble.RoboRumbleAtHome
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
Could not find the main class: roborumble.RoboRumbleAtHome. Program will exit.
./teamrumble.sh
Exception in thread "main" java.lang.NoClassDefFoundError: roborumble/RoboRumbleAtHome
Caused by: java.lang.ClassNotFoundException: roborumble.RoboRumbleAtHome
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
Could not find the main class: roborumble.RoboRumbleAtHome. Program will exit.
./twinduel.sh
Exception in thread "main" java.lang.NoClassDefFoundError: roborumble/RoboRumbleAtHome
Caused by: java.lang.ClassNotFoundException: roborumble.RoboRumbleAtHome
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
Could not find the main class: roborumble.RoboRumbleAtHome. Program will exit
Thanks for the update. I will have a deep look into this tonight and see how I can get this solved and write back as soon as I know what to do.
Unfortunately, I am not able to find the issue with the robocode.sh.in file, and I am not FreeBSD expert.
But one thing seems strange to me in the robocode.sh.in file. Why is this part entered twice?
-Djava.ext.dirs="%%DATADIR%%"
Another thing to try out would definitely be to writing this instead with the robocode.sh.in file:
That is, writing '-cp "%%DATADIR%%/libs/robocode.jar"' instead of just '-cp libs/robocode.jar'
If this work, the same should be fixed for the rest of the .sh files for Robocode, e.g. roborumble.sh, teamrumble.sh, meleerumble.sh etc.
The problem lies with the -cp option for the java command (exec "%%LOCALBASE%%/bin/java"), which needs to point to the correct /libs folder that is located under the robocode target folder.
Last edit: Flemming N. Larsen 2014-03-14
Yes this was one mistake twice used
-Djava.ext.dirs="%%DATADIR%%"
When I use
export JAVA_VERSION="%%JAVA_VERSION%%"
cd "%%DATADIR%%" && exec "%%LOCALBASE%%/bin/java" -Djava.ext.dirs="%%DATADIR%%" \ -cp "%%LOCALBASE%%/libs/robocode.jar" robocode.Robocode "${@}"
get
robocode
Exception in thread "main" java.lang.NoClassDefFoundError: robocode/Robocode
Caused by: java.lang.ClassNotFoundException: robocode.Robocode
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
Could not find the main class: robocode.Robocode. Program will exit.
%%LOCALBASE%% or %%PREFIX%% are usually /usr/local,
and robocode.jar is in %%ATADIR%%/libs/robocode.jar
Right is because is used cd "%%DATADIR%%"
export JAVA_VERSION="%%JAVA_VERSION%%"
cd "%%DATADIR%%" && exec "%%LOCALBASE%%/bin/java" -Djava.ext.dirs="%%DATADIR%%" \ -cp "./libs/robocode.jar" robocode.Robocode "${@}"
or
export JAVA_VERSION="%%JAVA_VERSION%%"
cd "%%DATADIR%%" && exec "%%LOCALBASE%%/bin/java" -Djava.ext.dirs="%%DATADIR%%" \ -cp "%%DATADIR%%/libs/robocode.jar" robocode.Robocode "${@}"
but not works :(
Last edit: nemysis 2014-03-14
I have gradually gone out of ideas. Everything looks fine to me.
However, one possibility remains. It could be the JVM (Java Virtual Machine) that is running out of memory when trying to load the classes. One crucial parameter from the original robocode.sh is missing. That is the
-Xmx512M
which allows up to 512 MB to be allocated on the heap. This might be the reason why the setup does not work with the new version of Robocode as it might need more memory than the previous version.I recommend you try something like:
or
You might try to remove the "${@}" part as well, as this is used to allow adding additional parameters for the original robocode.sh file like: ./robocode.sh -DmyParam=someThing
Notice that with the 'exec' command I removed lots of double-quotes (") from your version of robocode.sh.in, as the original version of robocode.sh state this:
Meaning: Run Java with out to max. 512 MB heap memory. Use the library libs/robocode.jar on the classpath and run the Java application robocode.Robocode.
It could also be done like this:
This would run Robocode from its jar file where the manifest file inside the robocode.jar tells Java to run robocode.Robocode when executed.
I really hope this helps. :-)
Last edit: Flemming N. Larsen 2014-03-15
I get now when use direct commands
cd /usr/local/share/java/robocode
java -Xmx512M -jar libs/robocode.jar
Invalid or corrupt jarfile libs/robocode.jar
java -Xmx512M -cp libs/robocode.jar robocode.Robocode
Exception in thread "main" java.lang.NoClassDefFoundError: robocode/Robocode
Caused by: java.lang.ClassNotFoundException: robocode.Robocode
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
Could not find the main class: robocode.Robocode. Program will exit.
java -Xmx512M -cp -jar libs/robocode.jar robocode.Robocode
Exception in thread "main" java.lang.NoClassDefFoundError: libs/robocode/jar
Caused by: java.lang.ClassNotFoundException: libs.robocode.jar
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
Could not find the main class: libs/robocode.jar. Program will exit.
ls /usr/local/share/java/robocode/libs
codesize-1.1.jar robocode.core-1.9.0.0.jar robocode.repository-1.9.0.0.jar robocode.ui.editor-1.9.0.0.jar
picocontainer-2.14.2.jar robocode.host-1.9.0.0.jar robocode.sound-1.9.0.0.jar roborumble.jar
robocode.battle-1.9.0.0.jar robocode.jar robocode.ui-1.9.0.0.jar
PS: how you format code?
You format code by surrounding it with a line of 6 tilde characters (
~~~~~~
) before and after the code. :-)The second command line from your post above fails as you put a '-cp' between -Xms512M and -jar:
Is should have been:
The thing that worries me is that the Java command in tells that the jarfile is invalid when you write:
Everybody else is able to run Robocode like this on other platforms like Windows, Mac OS X, Ubuntu Linux etc. So why should this be a problem on FreeBSD?
Which Java vendor and version of Java is you attempting to run Robocode with? Normally Robocode runs with the Oracle JRE or JDK version 6.0 or 7.0. OpenJDK is known to cause problems on some platforms.
Last edit: Flemming N. Larsen 2014-03-15
The Java version and vendor looks okay to me as well.
I am wondering if any files are missing from the /libs folder, where Robocode is installed. These files needs to be there:
codesize-1.1.jar
picocontainer-2.14.2.jar
robocode.battle-1.9.0.0.jar
robocode.core-1.9.0.0.jar
robocode.host-1.9.0.0.jar
robocode.jar
robocode.repository-1.9.0.0.jar
robocode.sound-1.9.0.0.jar
robocode.ui-1.9.0.0.jar
robocode.ui.editor-1.9.0.0.jar
roborumble.jar
The robocode.jar file is just a kickstarter, which will load libs/robocode.core-1.9.0.0.jar and locate RobocodeMainBase is start Robocode this way.
If your libs folder looks complete to you, then we need to examine why the robocode.jar is "invalid or corrupt" at your side? Perhaps you could send me this file to I could examine it to: fnl (at) users.sourceforge.net
I absolutely have no clue why Robocode 1.9.0.0 should not be able to run as "nothing" fundamental stuff other than internal API stuff has changed between version 1.8.3.0 and 1.9.0.0.
Just reinstalled Robocode
I have in this folder
Have deinstalled openjdk6
Are needed *.command to install?
In FreeBSD and GNU/Linux are not needed *.bat.
Have unpack robocode-1.9.0.0-setup.jar and from there works very good Robocode.
Have found Problem this was dos2unix, my mistake, sorry.
and forget to say only to change and delete ^M, could you this delete please from all files?
Now works and what is now best to use for commands, I look to make more Desktop files for Robocode, meleerumble, roborumble, teamrumble and twinduel. What are right Names?
Perhaps to use this for Desktop files?
robocode-Robocode.in
robocode-MeleeRumble.in
robocode-RoboRumble.in
robocode-TeamRumble.in
robocode-TwinDuel.in
Please look my other Port
http://www.freshports.org/games/domination/
and
http://svnweb.freebsd.org/ports/head/games/domination/files/
Last edit: nemysis 2014-03-16
First of all, I am really happy that you finally got Robocode up and running. :-D
You have a lot of comments and questions with your last post, so I will try to answer them all without forgetting some. ;-)
Normally, Robocode is installed on an OS by simply double-clicking the robocode-1.9.0.0-setup.jar file, which will normally start the 'java' or 'javaw' tool on the OS, if Java is properly installed. But you can also unpack and install Robocode manually by writting:
This will start the installer for Robocode, and normally the same thing happens when 'java' or 'javaw' is called by double-clicking Robocode from the UI / desktop. :-)
Please note that the installer is somewhat clever, so it will ONLY install .bat files on Windows, .command files under Mac OS X, and .sh files under Linux, FreeBSD etc.
Regarding the annoying Windows character (^M), I have already made a huge effort to remove it from the version system (CVS and Subversion in the pass, and now GitHub). Infact, it should be Unix style per default. But it could be due to the migration from SVN (Subversion) to GitHub that causes the fuzz. So I will definitely need to examine this in detail. Thank you for telling me about this issue that seems to have "risen from the dead". I will need to solve this for the coming version 1.9.1.0.
Here give give my comments for each of your *.in files.
robocode-Robocode.in (Desktop files) is okay
robocode-TeamRumble.in is okay
robocode-MeleeRumble.in is not okay, as it needs -Xmx1024 instead of -Xmx512 as melee battles are allowed to use double up on memory.
robocode-TwinDual.in should look like this:
That is, it should use the twinduel.txt as configuration file. :-)
That is all from me. I hope it will be easier with the coming version 1.9.1.0. I guess you won't need to change much (if anything), as the next version is focused on bug fixes and small adjustments.
Thank you so much for not giving up on Robocode and continuously trying to solve the problem. I really appreciate that and I am sure that FreeBSD users will benefit from this as well. =)
Last edit: Flemming N. Larsen 2014-03-16
I am really happy that FreeBSD can now use Robocode newest version. But is full usable when works good download for additional jar files.
Here in FreeBSD is usual to install Java applications with similar
This extract and is similar to
Thanks I have now changed these files, sorry this was yesterday night and I was very tired
Please change twinduel.sh to use ./roborumble/twinduel.txt, now is there roborumble.RoboRumbleAtHome ./roborumble/twinduul.txt
I have now make Desktop files for MeleeRumble, RoboRumble, TeamRumble and TwinDuel.
Could you to make Desktop entry files and supply with jar?
But now have problems with usage with these Games. Can't good dowload all needed files to work. Please look this paste (one month paste) is big to write here
http://pastebin.mozilla.org/4601701
Problem is that is not good download from Dropbox, GitHub, Google Docs and similar sites, which not permit direct download :(
Could you upload to your SF site all missing jar's in one zip or tar.gz?
Then can user or I with Makefile light download and extract to
./robots
Problems is too I think
At time only works robocode-Robocode or normal ./robocode.sh, please adjust that all works, thanks.
I have in Makefile to give users enough permissions to write into needed directories or use .sh scripts
Last edit: nemysis 2014-03-16
I have removed all ^M (Windows carrige-return) characters from all the files types you listed: .html .MF .battle .java .txt*.properties .tpt
If you find more, then don't hesitate with notifying me. :-)
the
robocode-MeleeRumble.in
androbocode-TwinDuel.in
looks correct now. :-)I fixed the twinduel.sh to use ./roborumble/twinduel.txt instead of ./roborumble/twinduul.txt on GitHub as well.
I dont understand your question: "Could you to make Desktop entry files and supply with jar?"
Do you mean if I could include all the *.in files like robocode-MeleeRumble.in in the robocode-1.9.x.x-setup file? If so, I will gladly include these for the future. :-)
But will that be sufficient or will it make sense to include even more - and which files in that case?
Hehe.. Actually, there is no problem with the RoboRumble, MeleeRumble, TeamRumble and TwinRumble. I am thinking on the stuff you put into http://pastebin.mozilla.org/4601701.
This is actually normal behaviour. As soon as these games starts up, a participant list (that is specific to the game type) is downloaded from the RoboWiki, and then participant robot archives are downloaded from web from this list. I don't maintain this list. The Robocoders (players) does this. Some robots might be (temporarily) unavailable from the web. The game takes this into account. So don't you worry about this. It works this way by design. =)
If you are curious, you can read more about the RoboRumble games here and how it is played: http://robowiki.net/wiki/RoboRumble
Regarding the this error message:
This is also AS IS by design. I might change that later, but it just the way the RoboRumble@Home client of Robocode works for the time being. The RoboRumble@Home client has been adopted by Robocode as somebody else coded these some years ago.
To me it seems that everything is up and running for Robocode - also the RoboRumble games. :-)
Last edit: Flemming N. Larsen 2014-03-16
Thanks for remove ^M (Windows carrige-return) characters. This must be removed here in FreeBSD.
I have mean to add to distributed package Desktop files.
I have readed more times
http://robowiki.net/wiki/Robocode
and
http://robowiki.net/wiki/Robocode
Is needed that I copy with Makefile 'net' directory?
But RoboRumble games not works here with scripts :(
Get similar for all after failed downloads
But I see that ./teamrumble.sh not so much download that robocode-TeamRumble?
And only ./twinduel.sh not not downlaod and not have this Java errors and robocode-TwinDuel download and fail.
Perhaps must use more similar design for robocode-* files.
Last edit: nemysis 2014-03-16
Hi again,
The issue you have seen:
... has been reported here as a bug report, and I am currently working on fixing it ASAP:
https://sourceforge.net/p/robocode/bugs/369/
I guess I will soon release version 1.9.1.0 of Robocode, since lots of other bugs have also been fixed waiting for a release.
Regarding the .desktop files. I guess these must be added to the robocode-1.9.x.x-setup.jar file and located in the root dir together with the .sh files? Am I right?
I also need to change the 'version' inside the files to e.g. 1.9.1.0 to fit the current version of Robocode?
Beside these files... will I need to include the .in files like the robocode.sh.in or is this something you handle on your side?
Last edit: Flemming N. Larsen 2014-03-17
Thanks for this bug 369.
Yes but best is to have one directory ./desktop in robocode-1.9.x.x-setup.jar file, and later copied to /usr/local/share/application, /usr/share/application or simple to ~/Desktop.
Yes is best to change 'version' inside the files to fit the current version of Robocode.
I must use files/*.in because FreeBSD. But here can be too used .sh files. I think .sh and .in files must be equable.
Okay. So I will include the .desktop files into a new ./desktop dir inside the robocode-1.9.x.x-setup.jar. Then I could update my installer to detect is the OS is FreeBSD. If so, I can copy the .desktop file to some target folder. :-)
I have one more question for you:
What should the target folder be?
1. /usr/local/share/application
2. /usr/share/application
3. ~/Desktop
Should it only be one of these directories, two of them (if so, which ones), all of them?
Thanks in advance.
When this has been settled I will make an new robocode-1.9.1.0-Alpha-X.jar file, which you can try out, i.e., it countains the .desktop files and contains bug fixes etc. But is not the real 1.9.1.0 release. It is just used for testing. ;-)
Last edit: Flemming N. Larsen 2014-03-18
Thanks for include these Desktop files. For all my Ports when is possible I make Desktop files and give to Upstream when possible.
In FreeBSD is used
/usr/local/share/application
and for local files user can use (to I)
~/Desktop
Yes I can test too Alpha and Beta version very light, thanks.
I have updated your .desktop files and attached these in this thread. I updated the GenericName, Comment and Icon fields according the the Desktop Entry file format so the user gets the correct descriptions etc.
I also changed the Icon field from 'robocode' into 'roborumble' with all RoboRumble related files. And I attached two .png files in 64x64 pixels for the two icon files (robocode and roborumble).
Last edit: Flemming N. Larsen 2014-03-18
Thanks many for these Desktop files and Icons. This is great. :D
It seems that Java is not allowed write to directories outside of the installation directory for Java. At least, it is not allowed to write to
/usr/local/share/application
.If I put the .desktop files into a "desktop" directory in the robocode directory, would you then be able to move or copy these files into
/usr/local/share/application
using your scripts when extracting Robocode? If so, I prefer this way out installing the .desktop files under FreeBSD as it gets too complicated to handle within the Robocode installer.Only put in "desktop" robocode directory, this is best.
All users in all OSes can copy desktop files to ~/Desktop.
I make this with Makefile to copy to /usr/local/share/application this works great. And can make this with all files and directories. Not are needed in FreeBSD Windows or OS X files.
Hi again,
I have now added the files for the recent Alpha-3 version of Robocode 1.9.1.0 containing the desktop files and other fixes as well, which you can try out. It can be downloaded from here:
http://robocode.sourceforge.net/files/robocode-1.9.1.0-Alpha-3-setup.jar
If you accept this one, I will soon release Robocode 1.9.1.0. :-)
Last edit: Flemming N. Larsen 2014-03-21