Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Step by step guide to get Scala to run on .net?

I have never used .Net framework and need to demonstrate to someone that Scala indeed works on .Net. I need to get a "quick and dirty" .Net setup with Scala working on some existing JVM Scala code. I could not find a step-by-step guide for this. I would appreciate some resources on this:

  1. How to install minimal .Net and which version to get Scala to work.
  2. How to install the .Net variant of Scala and which version to use (preferred 2.9).
  3. How to get hello world to run.

Thanks in advance. Platform in question: Windows 7 professional 32 bit.

like image 788
Jus12 Avatar asked Jul 26 '12 07:07

Jus12


People also ask

How do I run a scala file in CMD?

Executing Scala code as a script Another way to execute Scala code is to type it into a text file and save it with a name ending with “. scala”. We can then execute that code by typing “scala filename”. For instance, we can create a file named hello.

How do I compile and run a scala program?

Press "control o" to save the file and then press enter. Press "control x" to exit the nano editor. To compile the code, type "scalac hello_world. scala" and press enter.


1 Answers

Self-explaining file

helloworld.scala

/*
see https://github.com/magarciaEPFL/scaladotnet#readme
quick test
==========
1. Name this file helloworld.scala and put it in c:\scala-dotnettest
2. Download binaries from https://github.com/magarciaEPFL/scaladotnet/downloads and unpack the zipped files to the directory c:\scala-dotnet
3. Compile with: c:\scala-dotnet\scalacompiler -d c:\scala-dotnettest -target:exe -Xassem-extdirs c:\scala-dotnet -Xassem-name helloworld.exe -Xshow-class HelloWorld helloworld.scala
4. Copy runtime dependencies scalalib.dll, IKVM.OpenJDK.Core.dll, IKVM.OpenJDK.Util.dll and IKVM.Runtime.dll (or all IKVM*.dll) from c:\scala-dotnet to c:\scala-dotnettest
5. run helloworld
C:\scala-dotnettest>helloworld
Hello World!
*/ 
object HelloWorld extends App {
  println("Hello World!")
}
like image 110
Dave Avatar answered Oct 13 '22 09:10

Dave