# Invoking scala code from Kotlin File

**URL:** <https://discuss.kotlinlang.org/t/invoking-scala-code-from-kotlin-file/17113>\
**Category:** Language Design\
**Created:** [April 14, 2020, 7:35am UTC](https://discuss.kotlinlang.org/t/invoking-scala-code-from-kotlin-file/17113 "2020-04-14T07:35:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![engg.kanib](https://avatars.discourse-cdn.com/v4/letter/e/51bf81/32.png) [@engg.kanib](https://discuss.kotlinlang.org/u/engg.kanib)\
**Post date:** [April 14, 2020, 7:35am UTC](https://discuss.kotlinlang.org/t/invoking-scala-code-from-kotlin-file/17113/1 "2020-04-14T07:35:45Z")

</div>

Hi,  
I have a use-case where I want to invoke some functions that are written in Scala Object to be called from a kotlin file or Kotlin class. I am not finding anyway how to do it. I see that if the Scala is compiled ones separately then it gets called by the main in Kotlin file. But otherwise, it does not gets called.

Can someone here please help me how can this be done?

---

<div class="post-metadata">

**Author:** ![darksnake](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/darksnake/32/2479_2.png) [@darksnake](https://discuss.kotlinlang.org/u/darksnake)\
**Post date:** [April 14, 2020, 7:50am UTC](https://discuss.kotlinlang.org/t/invoking-scala-code-from-kotlin-file/17113/2 "2020-04-14T07:50:44Z")

</div>

You have scala code in the same project as kotlin code? In that case you need to meddle with build script to insure that scala compillation occurs before kotlin compillation. Here I have an old repository, where groovy code depends on kotlin code: [https://bitbucket.org/Altavir/dataforge/src/default/grind/build.gradle](https://bitbucket.org/Altavir/dataforge/src/default/grind/build.gradle). I think it should work the same way with scala.  
Kotlin has a two-side interop mechanism for java, but it does not work the same way with other JVM languages.

---

<div class="post-metadata">

**Author:** ![engg.kanib](https://avatars.discourse-cdn.com/v4/letter/e/51bf81/32.png) [@engg.kanib](https://discuss.kotlinlang.org/u/engg.kanib)\
**Post date:** [April 14, 2020, 10:35am UTC](https://discuss.kotlinlang.org/t/invoking-scala-code-from-kotlin-file/17113/3 "2020-04-14T10:35:34Z")

</div>

Thanks for the response @darksnake I have the Scala code in the same project. I am using maven for building the project. I will go through the repo you shared and see if this can work for me as well.
