# mainClass -\> unresolved reference

**URL:** <https://discuss.gradle.org/t/mainclass-unresolved-reference/40145>\
**Category:** Help/Discuss\
**Created:** [June 6, 2021, 9:59am UTC](https://discuss.gradle.org/t/mainclass-unresolved-reference/40145 "2021-06-06T09:59:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![idislikegradle](https://avatars.discourse-cdn.com/v4/letter/i/46a35a/32.png) [@idislikegradle](https://discuss.gradle.org/u/idislikegradle)\
**Post date:** [June 6, 2021, 9:59am UTC](https://discuss.gradle.org/t/mainclass-unresolved-reference/40145/1 "2021-06-06T09:59:05Z")

</div>

I am trying to follow the (very basic) instructions to create a runnable application, from here:  
[https://docs.gradle.org/6.6/userguide/application\_plugin.html](https://docs.gradle.org/6.6/userguide/application_plugin.html)

My file name is `build.gradle.kts`  
My settings file is `settings.gradle.kts`  
I have added `plugins { application }`  
and yet when I try `application { mainClass.set(...) }` I get an “Unresolved reference: mainClass” error

As you might guess, using the Groovy syntax (`mainClassName = "MainKt"`) works.

I just don’t understand how the instructions can be so simple yet resolving a problem is so difficult. The word “unresolved” doesn’t even appear on the page to help troubleshoot, nor is it possible to search within the docs.

---

<div class="post-metadata">

**Author:** ![jjustinic](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/jjustinic/32/9005_2.png) [@jjustinic](https://discuss.gradle.org/u/jjustinic)\
**Post date:** [June 7, 2021, 2:49am UTC](https://discuss.gradle.org/t/mainclass-unresolved-reference/40145/2 "2021-06-07T02:49:08Z")

</div>

> [@idislikegradle](#):
>
> The word “unresolved” doesn’t even appear on the page to help troubleshoot, nor is it possible to search within the docs.

An “Unresolved reference” is a generic programming term and is coming from the Kotlin compiler, not Gradle. It just means that you’re referencing something that isn’t defined.

> [@idislikegradle](#):
>
> and yet when I try `application { mainClass.set(...) }` I get an “Unresolved reference: mainClass” error
> 
> As you might guess, using the Groovy syntax ( `mainClassName = "MainKt"` ) works.

This is going to be less about the “Groovy syntax” and more about what the types of the properties and when they were introduced. The `mainClassName` property is a `String`. In Gradle `6.4`, the `mainClass` property was introduced, which is a `Property<String>`. While you’re referencing the Gradle `6.6` docs, based on what works, it looks like you’re actually executing the build with Gradle `6.3` (or earlier). The `mainClass` is unresolved because it hadn’t been added yet.
