Chapter 14Intermixing with Java

A few powerful Scala libraries are out there and more are being developed. Not only can you use these libraries from Scala, you can use them from Java as well. But to do so you have to learn a few tricks.

In this chapter, you’ll learn how to use Java classes from Scala and use Scala classes from Java. You can easily intermix Scala code with code written in Java and other languages on the JVM. Scala compiles into bytecode and you can package the generated class files into a JAR. Thus, you can use the generated bytecode from your Java and Scala applications. Make sure that the scala-library.jar file’s in your classpath, and you’re all set.

You’ll learn how Scala idioms manifest on the Java side. Knowing this, you ...

Get Pragmatic Scala now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.