"Code Too Large" Compilation Error in Java

Code too large compilation error in Java

A single method in a Java class may be at most 64KB of bytecode.

But you should clean this up!

Use .properties file to store this data, and load it via java.util.Properties

You can do this by placing the .properties file on your classpath, and use:

Properties properties = new Properties();
InputStream inputStream = getClass().getResourceAsStream("yourfile.properties");
properties.load(inputStream);

javac error code too large?

Methods in Java are restricted to 64k in the byte code. Static initializations are done in a single method (see link)


You may try to load the array data from a file.

Error: Code too large

Code is limited to 64K bytes and when you initialize an array you do this in code.

The best option is to store the data in a file and read the data you need. Note: the file can be deployed with the application and obtain directly from the archive.

Another option is to use a String instead (multiple Strings are not so limited in length) and parse it.

EDIT:

I suggest you write the data in a human readable form like

Cm7 Bm6 Am7 ....
Dm8 Cm7 Dm8 ....
....


Related Topics



Leave a reply



Submit