When uploading a java bot, a common mistake is to zip the root folder, and upload that. However, this leads the compiled java binary to look for a main class at <name_of_project>.main.MainClass, when it should be looking at main.MainClass.
It spent me 2 hours and 14 uploaded zip files to figure out what was going on. That's a waste of my time and your servers' resources.
A simple way to fix this problem is to check if the first (and only) folder in the zip file is the same name as the zip file.
A slightly more robust way to fix this problem is to warn the user if the uploaded zip file only contains one folder at its root.
A very robust way to fix this problem is to find a .java file somewhere (anywhere) in the zip file, and check that its package foo.bar; statement matches its directory: blah.zip/foo/bar.
In whatever solution is chosen, a warning should be given to the user with a description of how to properly create a zip file; it's best to avoid an error just in case it is a valid java project that just happens to have one root package with the same name as the project.
When uploading a java bot, a common mistake is to zip the root folder, and upload that. However, this leads the compiled java binary to look for a main class at
<name_of_project>.main.MainClass
, when it should be looking atmain.MainClass
.It spent me 2 hours and 14 uploaded zip files to figure out what was going on. That's a waste of my time and your servers' resources.
A simple way to fix this problem is to check if the first (and only) folder in the zip file is the same name as the zip file. A slightly more robust way to fix this problem is to warn the user if the uploaded zip file only contains one folder at its root. A very robust way to fix this problem is to find a .java file somewhere (anywhere) in the zip file, and check that its
package foo.bar;
statement matches its directory:blah.zip/foo/bar
.In whatever solution is chosen, a warning should be given to the user with a description of how to properly create a zip file; it's best to avoid an error just in case it is a valid java project that just happens to have one root package with the same name as the project.
Evidence others are having the same issue: https://booking.riddles.io/competitions/ms.-hack-man/discussions/discussion/b9a28cc3-78d3-4373-a0c2-987adb148336/1