1scalac(1)                        USER COMMANDS                       scalac(1)
2
3
4

NAME

6       scalac - Compiler for the Scala 2 language
7

SYNOPSIS

9       scalac  [ <options> ] <source files>
10

PARAMETERS

12       <options>
13              Command line options. See OPTIONS below.
14
15       <source files>
16              One or more source files to be compiled (such as MyClass.scala).
17

DESCRIPTION

19       The  scalac  tool  reads  class  and object definitions, written in the
20       Scala programming language,  and  compiles  them  into  bytecode  class
21       files.
22
23       By  default, the compiler puts each class file in the same directory as
24       its source file. You can specify a separate destination directory  with
25       -d (see OPTIONS, below).
26

OPTIONS

28       The  compiler  has  a set of standard options that are supported on the
29       current  development  environment  and  will  be  supported  in  future
30       releases. An additional set of non-standard options are specific to the
31       current virtual machine implementation and are subject to change in the
32       future.  Non-standard options begin with -X.
33
34   Standard Options
35       -Dproperty=value
36              Pass -Dproperty=value  directly to the runtime system.
37
38       -J<flag>
39              Pass <flag> directly to the runtime system.
40
41       -P:<plugin:opt>
42              Pass an option to a plugin
43
44       -X     Print a synopsis of advanced options.
45
46       -bootclasspath <path>
47              Override  location  of  bootstrap class files (where to find the
48              standard built-in classes, such as "scala.List").
49
50       -classpath <path>
51              Specify where to find user class files (on Unix-based systems  a
52              colon-separated list of paths, on Windows-based systems, a semi‐
53              colon-separate list of paths). This does not override the built-
54              in ("boot") search path.
55
56              The  default  class  path  is the current directory. Setting the
57              CLASSPATH variable or using the -classpath  command-line  option
58              overrides  that  default,  so if you want to include the current
59              directory in the search path, you must include "."  in  the  new
60              settings.
61
62       -d <directory|jar>
63              Specify where to place generated class files.
64
65       -deprecation
66              Emit warning and location for usages of deprecated APIs.
67
68              Available since Scala version 2.2.1
69
70       -encoding <encoding>
71              Specify character encoding used by source files.
72
73              The  default value is platform-specific (Linux: "UTF8", Windows:
74              "Cp1252"). Executing the following code in the Scala interpreter
75              will return the default value on your system:
76
77                  scala> new java.io.InputStreamReader(System.in).getEncoding
78
79       -explaintypes
80              Explain type errors in more detail.
81
82       -extdirs <dirs>
83              Override location of installed extensions.
84
85       -g:{none,source,line,vars,notailcalls}
86              "none" generates no debugging info,
87
88              "source" generates only the source file attribute,
89
90              "line" generates source and line number information,
91
92              "vars" generates source, line number and local variable informa‐
93              tion,
94
95              "notailcalls" generates all of the above and  will  not  perform
96              tail call optimization.
97
98       -help  Print a synopsis of standard options.
99
100       -javabootclasspath <path>
101              Override Java boot classpath.
102
103       -javaextdirs <path>
104              Override Java extdirs classpath.
105
106       -no-specialization
107              Ignore @specialize annotations.
108
109       -nobootcp
110              Do not use the boot classpath for the Scala jar files.
111
112       -nowarn
113              Generate no warnings
114
115       -optimise
116              Generates  faster bytecode by applying optimisations to the pro‐
117              gram.
118
119       -print Print program with all Scala-specific features removed.
120
121       -sourcepath <path>
122              Specify location(s) of source files.
123
124       -target:<target>
125              Specify which backend to use (jvm-1.5,msil).
126
127              The default value is "jvm-1.5" (was "jvm-1.4" up to  Scala  ver‐
128              sion 2.6.1).
129
130       -toolcp <path>
131              Add to the runner classpath.
132
133       -unchecked
134              Enable detailed unchecked (erasure) warnings
135
136              Non variable type-arguments in type patterns are unchecked since
137              they are eliminated by erasure
138
139              Available since Scala version 2.3.0
140
141       -uniqid
142              Uniquely tag all identifiers in debugging output.
143
144       -verbose
145              Output messages about what the compiler is doing
146
147       -version
148              Print product version and exit.
149
150       @<file>
151              A text file containing compiler arguments  (options  and  source
152              files)
153
154   Advanced Options
155       -Xassem-extdirs <dirs>
156              (Requires  -target:msil)  List  of directories containing assem‐
157              blies.  default:lib.
158
159       -Xassem-name <file>
160              (Requires -target:msil) Name of the output assembly.
161
162       -Xassem-path <path>
163              (Requires -target:msil) List of  assemblies  referenced  by  the
164              program.
165
166       -Xcheck-null
167              Warn upon selection of nullable reference
168
169       -Xcheckinit
170              Wrap  field  accessors  to  throw  an exception on uninitialized
171              access.
172
173       -Xdisable-assertions
174              Generate no assertions and assumptions
175
176       -Xelide-below <n>
177              Calls to @elidable methods are omitted  if  method  priority  is
178              lower than argument.
179
180       -Xexperimental
181              Enable experimental extensions
182
183       -Xfatal-warnings
184              Fail the compilation if there are any warnings.
185
186       -Xfuture
187              Turn on future language features.
188
189       -Xgenerate-phase-graph <file>
190              Generate the phase graphs (outputs .dot files) to fileX.dot.
191
192       -Xlint Enable recommended additional warnings.
193
194       -Xlog-implicits
195              Show more detail on why some implicits are not applicable.
196
197       -Xmax-classfile-name <n>
198              Maximum filename length for generated classes.
199
200       -Xmigration
201              Warn  about  constructs  whose behavior may have changed between
202              2.7 and 2.8.
203
204       -Xno-forwarders
205              Do not generate static forwarders in mirror classes.
206
207       -Xno-uescape
208              Disable handling of \u unicode escapes
209
210       -Xnojline
211              Do not use JLine for editing.
212
213       -Xplugin:<file>
214              Load a plugin from a file
215
216       -Xplugin-disable:<plugin>
217              Disable a plugin
218
219       -Xplugin-list
220              Print a synopsis of loaded plugins
221
222       -Xplugin-require:<plugin>
223              Abort unless the given plugin(s) are available
224
225       -Xpluginsdir <path>
226              Path to search compiler plugins.
227
228       -Xprint:<phases>
229              Print out program after <phases> (see below).
230
231       -Xprint-icode
232              Log internal icode to *.icode files.
233
234       -Xprint-pos
235              Print tree positions, as offsets.
236
237       -Xprint-types
238              Print tree types (debugging option).
239
240       -Xprompt
241              Display a prompt after each error (debugging option).
242
243       -Xresident
244              Compiler stays resident, files to compile are read from standard
245              input.
246
247       -Xscript <object>
248              Treat the source file as a script and wrap it in a main method.
249
250       -Xshow-class <class>
251              Show internal representation of class.
252
253       -Xshow-object <object>
254              Show internal representation of object.
255
256       -Xshow-phases
257              Print a synopsis of compiler phases.
258
259       -Xsource-reader <classname>
260              Specify a custom method for reading source files.
261
262       -Xsourcedir <path>
263              (Requires -target:msil) Mirror source folder structure in output
264              directory..
265
266       -Xverify
267              Verify generic signatures in generated bytecode.
268
269       -Y     Print a synopsis of private options.
270
271   Compilation Phases
272       initial
273              initializing compiler
274
275       parse  parse source files
276
277       namer  create symbols
278
279       analyze
280              name and type analysis
281
282       refcheck
283              reference checking
284
285       uncurry
286              uncurry function types and applications
287
288       lambdalift
289              lambda lifter
290
291       typesasvalues
292              represent types as values
293
294       addaccessors
295              add accessors for constructor arguments
296
297       explicitouterclasses
298              make links from inner classes to enclosing one explicit
299
300       addconstructors
301              add explicit constructor for each class
302
303       tailcall
304              add tail-calls
305
306       wholeprog
307              perform whole program analysis
308
309       addinterfaces
310              add one interface per class
311
312       expandmixins
313              expand mixins by code copying
314
315       boxing makes boxing explicit
316
317       erasure
318              type eraser
319
320       icode  generate icode
321
322       codegen
323              enable code generation
324
325       terminal
326              compilation terminated
327
328       all    matches all phases
329

ENVIRONMENT

331       JAVACMD
332              Specify the java command to be used for running the Scala  code.
333              Arguments  may be specified as part of the environment variable;
334              spaces, quotation marks, etc., will be passed  directly  to  the
335              shell for expansion.
336
337       JAVA_HOME
338              Specify JDK/JRE home directory. This directory is used to locate
339              the java command unless JAVACMD variable set.
340
341       JAVA_OPTS
342              Specify the options to be passed to the java command defined  by
343              JAVACMD.
344
345              With  Java 1.5 (or newer) one may for example configure the mem‐
346              ory usage of the JVM  as  follows:  JAVA_OPTS="-Xmx512M  -Xms16M
347              -Xss16M"
348
349              With  GNU  Java one may configure the memory usage of the GIJ as
350              follows: JAVA_OPTS="--mx512m --ms16m"
351

EXAMPLES

353       Compile a Scala program to the current directory
354              scalac HelloWorld
355
356       Compile a Scala program to the destination directory classes
357              scalac -d classes HelloWorld.scala
358
359       Compile a Scala program using a user-defined java command
360              env  JAVACMD=/usr/local/bin/cacao   scalac   -d   classes   Hel‐
361              loWorld.scala
362
363       Compile all Scala files found in the source directory src to the desti‐
364       nation directory classes
365              scalac -d classes src/*.scala
366

EXIT STATUS

368       scalac returns a zero exist status if it succeeds to compile the speci‐
369       fied input files. Non zero is returned in case of failure.
370

AUTHOR

372       Written by Martin Odersky and other members of the Scala team.
373

REPORTING BUGS

375       Report bugs to https://issues.scala-lang.org/.
376
378       This  is  open-source  software,  available  to  you  under  a BSD-like
379       license. See accomponying "copyright" or  "LICENSE"  file  for  copying
380       conditions.  There is NO warranty; not even for MERCHANTABILITY or FIT‐
381       NESS FOR A PARTICULAR PURPOSE.
382

SEE ALSO

384       fsc(1), scala(1), scaladoc(1), scalap(1)
385
386
387
388version 1.0                       March 2012                         scalac(1)
Impressum