What is a .scala file?
Scala Source File · Code and data · Martin Odersky / EPFL · 2004
A .scala file is Scala source code, a language that blends object-oriented and functional programming and runs on the Java Virtual Machine. It is used for data engineering, backends and Apache Spark jobs.
What is a .scala file used for?
Scala compiles to JVM bytecode and interoperates with Java, so it fits into existing Java ecosystems while offering a more concise, expressive style. It is the language of Apache Spark, which made it popular in big data.
The files are plain text and open in any editor; IntelliJ IDEA with the Scala plugin is the common setup.
How to open a .scala file
The .scala format opens in the following apps, grouped by operating system. If one app does not work, try another from the same list. For a step-by-step walkthrough, see how to open a .scala file.
Windows
- IntelliJ IDEA
- VS Code (Metals)
- any text editor
macOS
- IntelliJ IDEA
- VS Code (Metals)
- any text editor
Linux
- IntelliJ IDEA
- VS Code (Metals)
- any text editor
How to convert a .scala file
You can convert a .scala file to class (bytecode), jar using a conversion tool or the export menu of an app that opens it.
.scala file signature (magic bytes)
Programs recognise a .scala file by the bytes at the start of the file, not by its name. These are the signatures for Scala.
| Hex signature | Offset | Note |
|---|---|---|
| (no fixed signature) | 0 | plain text; no fixed magic bytes |
See the full magic-numbers reference for every format.
Frequently asked questions
What is a .scala file?
A .scala file is Scala source code, a language that blends object-oriented and functional programming and runs on the Java Virtual Machine. It is used for data engineering, backends and Apache Spark jobs.
How do I run a .scala file?
With Scala installed, run scala file.scala for a quick script, or build a project with sbt. IntelliJ IDEA can compile and run it too.
Does Scala run on the JVM?
Yes. Scala compiles to Java bytecode and interoperates with Java libraries, though Scala.js and Scala Native target JavaScript and native code as well.
Why is Scala used with Apache Spark?
Spark is written in Scala and exposes its richest, fastest API there, so data engineers often write Spark jobs in .scala files.
Related formats
Sources
Details on this page were checked against authoritative references: