3

I'm trying to create a Dll out of a scala-class. I'm using IntelliJ together with SBT. I've already found a way to convert .jar files into a Dll, using the ikvm-converter. Now the problem: When I use "package" under SBT to create a .jar file out of my .scala file and try to convert it afterwards with ikvmc into a Dll the resulting library is empty when integrated in C#...

For example converting the Jama-Library (which is written in Java) works fine, where converting Scama (written in Scala) does not work.

Is there a way to do this conversion of scala code into a dll? Is there a "Scala to Java"-conversion tool?

Best Regards, Christoph

0__
  • 66,707
  • 21
  • 171
  • 266
user1537137
  • 121
  • 5
  • Are you including your scala runtime jars into your conversion as well? Please show your ikvmc command line. – SK-logic Jul 19 '12 at 07:57
  • Scala compiles to Java bytecode, so there is no reason Scala itself poses some problems with IKVMC. When you compile Scala, you get a Java Class. It looks like the problem is that Scama API has not the right visibility rules to be accessible from C# when converted through IKVM – Edmondo Jul 19 '12 at 07:58
  • ikvmc -target:library jama-1.0.2.jar – user1537137 Jul 19 '12 at 08:06
  • ikvmc -target:library scama_2.9.0-1.0.jar This gives me to .dll files. When converting the scama library, I get warnings, when converting Jama I do not get warnings. – user1537137 Jul 19 '12 at 08:07
  • Try converting this jar alongside with all of the dependencies. – SK-logic Jul 19 '12 at 10:42

1 Answers1

3

I have no knowledge of .NET, but judging from SK-logic's and your comments to the questions: sbt package does not include the Scala runtime library, because it assumes you are going to export your project as a library to be used within other Scala projects.

Therefore, you will need to create a "fat" jar that contains the runtime. For example, in this blog you can see how the author creates a fully self-contained executable, by converting both the project jar and the runtime jar.

There are different tools to do that with sbt. The easiest would be sbt-assembly, but you will end up with a very large file, because it just adds the whole runtime. If that is a problem, you may want to filter the runtime instead, using the proguard plugin. More on this topic in another StackOverflow entry.

Community
  • 1
  • 1
0__
  • 66,707
  • 21
  • 171
  • 266
  • 2
    Not necessarily one fat jar, you can process a number of jars simultaneously (and it is a recommended way of using ikvmc). – SK-logic Jul 19 '12 at 12:11