Linux command
scalac 命令
趣味
复制后可按需替换文件名、目录或参数。
常用示例
Compile a Scala source file
scalac [Hello.scala]
Compile multiple files
scalac -d [classes/] [*.scala]
Compile with classpath
scalac -classpath [lib/*] [Source.scala]
Compile with verbose output
scalac -verbose [Source.scala]
Compile with additional warnings
scalac -Xlint [Source.scala]
Treat warnings as errors
scalac -Werror [Source.scala]
Show compiler version
scalac -version
说明
scalac is the compiler for the Scala programming language. It reads Scala source files (.scala) and compiles them into Java bytecode class files that run on the JVM. By default, class files are placed in the same directory as their source files. Use -d to specify an alternate output directory or JAR file. The compiler integrates with Java classes via the classpath mechanism. Options are categorized by prefix: -W for warnings, -V for verbose output, -X for extended options, and -Y for private/experimental options.
参数
- -d _directory|jar_
- Specify where to place generated class files
- -classpath _path_
- Specify where to find user class files (colon-separated on Unix)
- -bootclasspath _path_
- Override location of bootstrap class files
- -sourcepath _path_
- Specify where to find input source files
- -verbose
- Output messages about what the compiler is doing
- -deprecation
- Emit warning and location for usages of deprecated APIs
- -unchecked
- Enable additional warnings for type erasure
- -Werror
- Fail compilation if there are any warnings
- -Xlint
- Enable recommended additional warnings
- -version
- Print product version and exit
- -help
- Print synopsis of standard options
FAQ
What is the scalac command used for?
scalac is the compiler for the Scala programming language. It reads Scala source files (.scala) and compiles them into Java bytecode class files that run on the JVM. By default, class files are placed in the same directory as their source files. Use -d to specify an alternate output directory or JAR file. The compiler integrates with Java classes via the classpath mechanism. Options are categorized by prefix: -W for warnings, -V for verbose output, -X for extended options, and -Y for private/experimental options.
How do I run a basic scalac example?
Run `scalac [Hello.scala]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -d _directory|jar_ do in scalac?
Specify where to place generated class files