# I got the java.lang.reflect.InvocationTargetException in my code

**URL:** <https://discourse.processing.org/t/i-got-the-java-lang-reflect-invocationtargetexception-in-my-code/22374>\
**Category:** Coding Questions\
**Created:** [July 4, 2020, 9:28am UTC](https://discourse.processing.org/t/i-got-the-java-lang-reflect-invocationtargetexception-in-my-code/22374 "2020-07-04T09:28:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![yurim](https://avatars.discourse-cdn.com/v4/letter/y/858c86/32.png) [@yurim](https://discourse.processing.org/u/yurim)\
**Post date:** [July 4, 2020, 9:28am UTC](https://discourse.processing.org/t/i-got-the-java-lang-reflect-invocationtargetexception-in-my-code/22374/1 "2020-07-04T09:28:02Z")

</div>

> I’m making calendar program in processing. In the process of adding a schedule for each day, I should make Plan\_Day class array in This\_Day class. But I got java.lang.reflect.InvocationTargetException on and over again. Please help me 😢

> The part of main code is,

```
 This_Day[] days = new This_Day[300];
 for(int row = 0; row < rowCount; row++) {
 start = data.getString(row, 1);
 end = data.getString(row, 2);
 if(start == null) {
   start = end;
 }
 if(end == null) {
   end = start;
 }
 try{
   d_start = formatter2.parse(start);
   d_end = formatter2.parse(end);
 }
 catch(ParseException e){}
 int day_gap1 = m_date.compareTo(d_start);
 int day_gap2 = M_date.compareTo(d_end);
 if(day_gap1 <=0 && day_gap2 >= 0) {
   Plan_Day p = new Plan_Day(d_start, d_end, data.getString(row, 3), data.getString(row, 4), data.getInt(row, 5));
   days[(int)p.plan_num].day_append(p);
 }
}
for(int i = 0; i < days.length; i++) {
    days[i].day_put();
    if(keyPressed == true && key == ' '){
      days[i].day_putdata();
    }
}

```

> Then the Plan\_Day class is,

```
public class Plan_Day{
Date start, end; 
String title, discription, f_start, f_end;
int done, plan_count_num;
long plan_num;
Plan_Day (Date s, Date e, String t, String d, int don) {
  start = s;
  end = e;
  title = t;
  discription = d;
  done = don;
  f_start = formatter2.format(start);
  plan_num = (end.getTime()-m_date.getTime())/(24*60*60*1000);
}

void put(int t) {
  fill(0);
  text(title+" "+plan_num, 0, 0);
  font = createFont("Content1.TTF", 30);
  textFont(font);
  pushMatrix();
  rotate(2*PI*plan_num/n);
  rectMode(CENTER);
  fill(#F2F2F2);
  stroke(#262626);
  rect(0, -100-50*t, 100*sin(2*PI/n), 150, 5);
  popMatrix();
}
void putdate(int t) {
  fill(0);
  text(title, (200+50*t)*sin(2*PI*plan_num/n), -(200+50*t)*cos(2*PI*plan_num/n));
  text(f_start, (300+50*t)*sin(2*PI*plan_num/n), -(300+50*t)*cos(2*PI*plan_num/n));
}

```

}

> The This\_Day class is,

```
public class This_Day {
  Plan_Day[] plans;
  Date this_day;
  int num;
  This_Day() {
  }
  void day_append(Plan_Day p){
    plans = (Plan_Day[]) append(plans, p);
  }
  void day_put() {
    if(plans.length == 0) return;
    for(int i = 0; i < plans.length; i++) {
     plans[i].put(i);
    }
  }
  void day_putdata(){
    for(int i = 0; i < plans.length; i++) {
      plans[i].putdate(i);
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [July 4, 2020, 11:49am UTC](https://discourse.processing.org/t/i-got-the-java-lang-reflect-invocationtargetexception-in-my-code/22374/2 "2020-07-04T11:49:16Z")

</div>

If you are running this in Processing then you will get error messages in the console pane - the text will be red.

As soon as you get the error message stop the the application to prevent further error being printed. In the console window you will see a lot of red text - since you are getting the error repeatably a lot of the text will be duplicated. if you look carefully you will find the stack-trace printed (lots of them) when the exception is thrown. The stack-trace can extend over several lines but you should be able to identify a single one which you might copy and post here so we can help more.

BTW welcome to the forum 😄
