# java.lang.ClassCastException

**URL:** <https://forum.katalon.com/t/java-lang-classcastexception/20412>\
**Category:** API Testing\
**Tags:** api-testing, katalon-studio\
**Created:** [March 4, 2019, 6:54am UTC](https://forum.katalon.com/t/java-lang-classcastexception/20412 "2019-03-04T06:54:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rajan.chavda](https://avatars.discourse-cdn.com/v4/letter/r/9de0a6/32.png) [@rajan.chavda](https://forum.katalon.com/u/rajan.chavda)\
**Post date:** [March 4, 2019, 6:54am UTC](https://forum.katalon.com/t/java-lang-classcastexception/20412/1 "2019-03-04T06:54:11Z")

</div>

I am experiancing weird error. While I type or do any stuff in my current project this error dialogue box appears frequently

 ![Screenshot%20(92)](https://europe1.discourse-cdn.com/katalon/original/2X/7/7350360608f1d08a2c3dfd4e90dabcfae2103ee5.png) .

---

<div class="post-metadata">

**Author:** ![Brian\_Ducson](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/brian_ducson/32/603_2.png) [@Brian\_Ducson](https://forum.katalon.com/u/Brian_Ducson)\
**Post date:** [March 4, 2019, 9:09am UTC](https://forum.katalon.com/t/java-lang-classcastexception/20412/2 "2019-03-04T09:09:13Z")

</div>

Could you try to download another build of Katalon and reinstall it?

---

<div class="post-metadata">

**Author:** ![kevinkatler](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kevinkatler/32/16104_2.png) [@kevinkatler](https://forum.katalon.com/u/kevinkatler)\
**Post date:** [July 12, 2021, 7:02am UTC](https://forum.katalon.com/t/java-lang-classcastexception/20412/3 "2021-07-12T07:02:26Z")

</div>

The exaception thrown to indicate that your code has attempted to cast an object to a subclass of which it is not an instance. This means that ClassCastException occurs when you try to cast an instance of an Object to a type that it is not. [Type Casting](http://net-informations.com/java/basics/casting.htm) only works when the casted object follows an is a relationship to the type you are trying to cast to.

It is good practice to guard any explicit casts with an instanceof check first:

```
if (myApple instanceof Fruit) {
  Fruit myFruit = (Fruit)myApple;
}

```

When will be ClassCastException is thrown:

- When you try to cast an object of Parent class to its Child class type, this exception will be thrown.

- When you try to cast an object of one class into another class type that has not extended the other class or they don’t have any relationship between them.

---

<div class="post-metadata">

**Author:** ![albert.vu](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/albert.vu/32/20595_2.png) [@albert.vu](https://forum.katalon.com/u/albert.vu)\
**Post date:** [August 8, 2022, 7:31am UTC](https://forum.katalon.com/t/java-lang-classcastexception/20412/4 "2022-08-08T07:31:32Z")

</div>

Archived on August 8, 2022, 7:31am UTC


