How to fix "The code of method .. is exceeding the 65535 bytes limit"?

The error code seems quite self-explanatory.

The code of method main(String[]) is exceeding the 65535 bytes limit 

This is because there is an arbitrary hard-coded limit in Java of 64Kb for method sizes. (And actually many other things are limited to 64K, such as method names, the number of constants, etc. See the Java 8 specs or the Java 7 specs for more details.)

To work around this, all you have to do is break up your main(String[] args) method into multiple sub-methods.


But why not just load the names from a file instead?

Some of the issues with doing it the way you are currently proposing are:

  • firstly, you're hard-coding details, which is almost always a bad thing (See this);

  • secondly, you're getting that error message; and

  • thirdly, you make your code very difficult to read.

There are many more, of course, but these are the obvious ones.


In java a methods can't have more than 65535 bytes.

So to fix this problem, break up your main(String[] args) method in to multiple sub methods.