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

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: roger, 99jonathan, imaqine

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

Postby samu » Fri Jan 25, 2013 5:41 pm

Hello,
I have programmed a programm which is scanning a DinA4 paper, storing the values in a Matrix and printing it out again with a pen.
Now, after adding some lines to my program it shows me this error in Eclipse:
The code of method main(String[]) is exceeding the 65535 bytes limit
Does someone of you have any idea how to solve this problem ?

Actually I'm thinking of splitting the programm into two parts, but is this possible, and what is with my Variables/Matrix in the program then? How do I get them public, because both parts of the program will need them

Thanks in advance
Sorry for my English :D
samu
New User
 
Posts: 3
Joined: Fri Jan 25, 2013 5:27 pm

Re: method main(String[]) is exceeding the 65535 bytes limit

Postby skoehler » Fri Jan 25, 2013 8:12 pm

Your main-method is very long. Shorten it. Split the task that the main method solves in several smaller ones, and implement a method each.
Now you may argue, that your main method is not THAT long. You didn't provide any code, but an educated guess would be, that you initialize a rather huge array in the main method. Well, then my comment above doesn't really apply. One thing you should know about Java, is that array inialization generated byte-code. Hence, you easily exceed the 64KB limit for a method, even though it does not contain to much code. Don't initialize arrays like that. Save the data in a file, and upload the file along with the NXT. Then load that file into an array. Alternatively, you can encode the data into a Java String (which is somewhat tricky due to when the \uXXXX escapes are replaced), and then convert the String to the array you intend to create.
skoehler
leJOS Team Member
 
Posts: 1114
Joined: Thu Oct 30, 2008 4:54 pm

Re: method main(String[]) is exceeding the 65535 bytes limit

Postby samu » Tue Jan 29, 2013 5:12 am

Thank you for help.
The program was very long, and i already tried to split it in parts, but my main problem was the variables, which were not public, so i couldn share them between parts of the prgm. Now a friend helped me (the declaration has to be before main()) and he also gave me a little more help (now i knpw | ,& and << ) which will shorten my prgm very much (instead of 12000lines there will be perhaps 5000 Only)
Sorry for my English :D
samu
New User
 
Posts: 3
Joined: Fri Jan 25, 2013 5:27 pm


Return to NXJ Software

Who is online

Users browsing this forum: Google [Bot] and 1 guest

more stuff