Target VM failed to initialize

Hi there people of processing!

I'm trying to compare the values of an integer variable and a two-dimensional integer array and this is the code I'm using:

int[][] BandNoten = { {0,0,0,0,0,0,0,0,0,20,22,23},
                {24,26,27,29,31,32,34,36,39,41,43,46},
                {49,51,55,58,61,65,69,73,77,82,87,92},
                {97,103,109,116,122,130,137,146,154,163,173,183},
                {193,206,218,231,245,259,275,291,309,327,346,367},
                {389,412,436,462,490,519,550,583,617,654,693,734},
                {778,824,873,925,980,1038,1100,1165,1234,1308,1386,1468},
                {1555,1648,1746,1849,1959,2076,2199,2330,2469,2615,2771,2936},
                {3110,0,0,0,0,0,0,0,0,0,0,0}};
int test =3110;


void draw() {

  for (int j = 0; j < 11; j++){
    for (int k = 0; k < 8; k++) {
      if (BandNoten[j][k] == test){
        print(BandNoten[j][k]);

    }}}}

After starting the program it writes down the correct number into the console but then the program just stops and the rainbow wheel of doom appears. In he console it says:

3110Could not run the sketch (Target VM failed to initialize).
For more information, read revisions.txt and Help → Troubleshooting.

This is just a small part of a program trying to visualize music as it is played and i really need to find an answer to this problem.

Excuse my bad english!

Donny

Tagged:

Answers

  • edited January 2014 Answer ✓

    Please, when posting a code, highlight it and hit CTRL+K to format it. :-w

    Your array is 9 rows x 12 cols. But it seems like you're trying to iterate over it as it was 12 rows x 9 cols! #-o

    Anyways, here's my tweaked version using enhanced loops.
    So there's no need to guess the array's dimensions by ourselves! (*)

    // forum.processing.org/two/discussion/2411/target-vm-failed-to-initialize
    
    final short[][] bands = { 
      {
        0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 22, 23
      }
      , {
        24, 26, 27, 29, 31, 32, 34, 36, 39, 41, 43, 46
      }
      , {
        49, 51, 55, 58, 61, 65, 69, 73, 77, 82, 87, 92
      }
      , {
        97, 103, 109, 116, 122, 130, 137, 146, 154, 163, 173, 183
      }
      , {
        193, 206, 218, 231, 245, 259, 275, 291, 309, 327, 346, 367
      }
      , {
        389, 412, 436, 462, 490, 519, 550, 583, 617, 654, 693, 734
      }
      , {
        778, 824, 873, 925, 980, 1038, 1100, 1165, 1234, 1308, 1386, 1468
      }
      , {
        1555, 1648, 1746, 1849, 1959, 2076, 2199, 2330, 2469, 2615, 2771, 2936
      }
      , {
        3110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
      }
    };
    
    final short test = 3110;
    
    for (short[] cols: bands) // each cols is a row from bands.
      for (short elem: cols)  if (elem == test)  print(elem);
    
    exit();
    
  • haha ok that was dumb ;D thanks a lot!

Sign In or Register to comment.