# Class 'kotlin.KotlinPackage' was compiled with an incompatible version of Kotlin

**URL:** <https://discuss.kotlinlang.org/t/class-kotlin-kotlinpackage-was-compiled-with-an-incompatible-version-of-kotlin/871>\
**Category:** Uncategorized\
**Created:** [April 1, 2013, 11:21am UTC](https://discuss.kotlinlang.org/t/class-kotlin-kotlinpackage-was-compiled-with-an-incompatible-version-of-kotlin/871 "2013-04-01T11:21:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![freewind](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/freewind/32/1479_2.png) [@freewind](https://discuss.kotlinlang.org/u/freewind)\
**Post date:** [April 1, 2013, 11:21am UTC](https://discuss.kotlinlang.org/t/class-kotlin-kotlinpackage-was-compiled-with-an-incompatible-version-of-kotlin/871/1 "2013-04-01T11:21:12Z")

</div>

I tried to invoke kotlin compiler from Java code, and when I execute it from IDEA, it reports such error:

\> ERROR: X:WORKSPACEdive\_in\_playInvokeCompilerslibkotlin-runtime.jar!/kotlin/KotlinPackage.class: (-1, 136) Class 'kotlin.KotlinPackage' was compiled with an incompatible version of Kotlin. Its ABI version is 2, expected ABI version is 1 \> ERROR: X:WORKSPACEdive\_in\_playInvokeCompilerslibkotlin-runtime.jar!/kotlin/io/IoPackage.class: (-1, 139) Class 'kotlin.io.IoPackage' was compiled with an incompatible version of Kotlin. Its ABI version is 2, expected ABI version is 1

My code is simple:

```kotlin
import org.jetbrains.jet.cli.common.CLICompiler;
import org.jetbrains.jet.cli.common.ExitCode;
import org.jetbrains.jet.cli.jvm.K2JVMCompiler;
import org.jetbrains.jet.cli.jvm.K2JVMCompilerArguments;

import java.util.ArrayList;
import java.util.List;
/**

User: Administrator

Date: 13-4-1

Time: 下午12:33
*/
public class CompileByKotlin {
  private static final String ROOT = “X:\WORKSPACE\dive_in_play\InvokeCompilers”;
  private static final String SOURCES = ROOT + “\kotlin-data\sources”;
  private static final String BYTECODES = ROOT + “\kotlin-data\bytecodes”;
  public static void main(String args) {
  K2JVMCompilerArguments arguments = new K2JVMCompilerArguments();
  List<String> sourcesList = new ArrayList();
  sourcesList.add(SOURCES);
  arguments.setSourceDirs(sourcesList);
  arguments.setOutputDir(BYTECODES);
  arguments.noJdkAnnotations = true;
  arguments.setClasspath(ROOT + “\lib”);
&nbsp;&nbsp;CLICompiler compiler = new K2JVMCompiler();
&nbsp;&nbsp;final ExitCode exitCode = compiler.exec(System.err, arguments);
&nbsp;&nbsp;if (exitCode != ExitCode.OK) {

           System.out.println("Error: " + exitCode);
  }
  }
}

 
```

And there are a sources dir which contains 2 kotlin files:

---

<div class="post-metadata">

**Author:** ![freewind](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/freewind/32/1479_2.png) [@freewind](https://discuss.kotlinlang.org/u/freewind)\
**Post date:** [April 1, 2013, 11:24am UTC](https://discuss.kotlinlang.org/t/class-kotlin-kotlinpackage-was-compiled-with-an-incompatible-version-of-kotlin/871/2 "2013-04-01T11:24:30Z")

</div>

Sorry, it submits before I complete.

AAA.kt

``

```kotlin
fun main(args: Array<String>) {
  BBB().hello();
}
```

BBB.kt

``

```kotlin
class BBB {
  fun hello(){
  println(“Hello, Kotlin!”)
  }
}
```

And in my “lib” directory, there are two kotlin jars:

- kotlin-compiler.jar
- kotlin-runtime.jar

Which comes from "kotlin-compiler-0.5.1".

And I have installed Kotlin-plugin in my IDEA.

I have tried to find the solution more than 1 hour, still not found the reason yet. So I ask it here for help.

---

<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 1, 2013, 11:51am UTC](https://discuss.kotlinlang.org/t/class-kotlin-kotlinpackage-was-compiled-with-an-incompatible-version-of-kotlin/871/3 "2013-04-01T11:51:40Z")

</div>

You kotlin-compiler.jar and kotlin-runtime.jar a re out of sync: they come from different version sof Kotlin

---

<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 1, 2013, 11:52am UTC](https://discuss.kotlinlang.org/t/class-kotlin-kotlinpackage-was-compiled-with-an-incompatible-version-of-kotlin/871/4 "2013-04-01T11:52:52Z")

</div>

Also, you can use forward slashes in paths inside Java strings

---

<div class="post-metadata">

**Author:** ![freewind](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/freewind/32/1479_2.png) [@freewind](https://discuss.kotlinlang.org/u/freewind)\
**Post date:** [April 1, 2013, 11:55am UTC](https://discuss.kotlinlang.org/t/class-kotlin-kotlinpackage-was-compiled-with-an-incompatible-version-of-kotlin/871/5 "2013-04-01T11:55:56Z")

</div>

Thank you so much!

I just deleted them, and copy the two files from kotlin-compiler-0.5.1 again, everything work well this time!
