# Compiling Kotlin class inside application

**URL:** <https://discuss.kotlinlang.org/t/compiling-kotlin-class-inside-application/282>\
**Category:** Uncategorized\
**Created:** [April 14, 2015, 6:06pm UTC](https://discuss.kotlinlang.org/t/compiling-kotlin-class-inside-application/282 "2015-04-14T18:06:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![msgile](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/msgile/32/1484_2.png) [@msgile](https://discuss.kotlinlang.org/u/msgile)\
**Post date:** [April 14, 2015, 6:06pm UTC](https://discuss.kotlinlang.org/t/compiling-kotlin-class-inside-application/282/1 "2015-04-14T18:06:19Z")

</div>

Currently we Kotlin extensively in our serverside application.&nbsp;&nbsp;We want to create small scripts in Kotlin for single use task, and send them to the server to be compiled and run from our current running jvm.&nbsp;&nbsp;How can we access the compiler? is there a way to make it use the current running classpath for compilation?&nbsp;&nbsp;

Thank you - Matt

---

<div class="post-metadata">

**Author:** ![abreslav](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/abreslav/32/8279_2.png) [@abreslav](https://discuss.kotlinlang.org/u/abreslav)\
**Post date:** [April 15, 2015, 3:22pm UTC](https://discuss.kotlinlang.org/t/compiling-kotlin-class-inside-application/282/2 "2015-04-15T15:22:52Z")

</div>

There's no out-of-the-box way of doing this. The compiler can be used by calling kotlin-compiler.jar classes (use at your own risk, there's no public API yet), but passing the loaded classpath is not supported, you'll need to inspect URLClassLoader's at runtime or do something similar.

If you decide to go this way, feel free to ask questions about the compiler classes
