Scala compiled bytecode can be easily integrated into existing Java applications. This is possible because the Scala compiler produces normal Java bytecode . As runtime
should come here Java 5.0 or newer to use.
given a scale installation is required. The best take the IzPack installer . The installation directory is in the following example, the scala-2.7.7 ". object Hello extends Application {scala world
println ("Hello Scala!")}
This executable singleton object stores it as a file "HalloScalaWelt.scala" which is now translated and performed: HeartOfGold: ~ $
much scalac HalloScalaWelt.scalaHeartOfGold. ~ $ much scala scala hello world Hello Scala! Already any Java beginner in this case it looks familiar commands. Accordingly, we run the generated class files can just be a Java application:
HeartOfGold: ~ $ much java-cp scala-2.7.7/lib/scala-library.jar. Hello world
scala Scala Hi!or
On Windows you have the classpath (-cp option
-classpath
) before the period at the end (current directory) to a semicolon instead of colon. just as easily can be integrated Scala code into existing Java applications. It simply takes the compiled class files and sets
scala-library.jar
on the classpath - done!
The use of classes between Java and Scala is often, quite simply, as usual, to use the (fully qualified or imported) class name.
0 comments:
Post a Comment