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.
What opens 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.
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
Open a .scala file step by step
- Confirm the file really is a .scala. Drop it into the WhatFileType identifier, which reads its signature in your browser without uploading anything.
- On Windows, open it with IntelliJ IDEA or VS Code (Metals).
- On Mac, use IntelliJ IDEA or VS Code (Metals).
- On Linux, try IntelliJ IDEA or VS Code (Metals).
- Still stuck? Convert the .scala to class (bytecode), which opens more widely.
Why can't I open my .scala file?
Almost always because no installed app understands Scala. Install one of the apps above, or convert the file to a format your existing software already reads. If double-clicking opens the wrong program instead of nothing at all, the file association is set to the wrong app rather than the file being broken.
The other possibility is that the file is not really a .scala at all. Drop it into the file identifier to check it by its bytes instead of its name. Nothing is uploaded.
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 has no fixed magic number, so there is no signature table on this page. Its bytes alone do not prove the format: identification relies on the extension, the structure of the content and the program that created it. The magic-numbers reference lists the formats that do carry one.
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. How sources are ranked and what is deliberately left out is set out in the methodology.