"Fossies" - the Fresh Open Source Software Archive

Member "scala-2.13.9/doc/tools/scala.html" (19 Sep 2022, 9835 Bytes) of package /windows/misc/scala-2.13.9.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) HTML source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

A hint: This file contains one or more very long lines, so maybe it is better readable using the pure text view mode that shows the contents as wrapped lines within the browser window.


    1 <?xml version="1.1" encoding="iso-8859-1"?>
    2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    3 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    4 
    5 <head>
    6 <title>scala man page</title>
    7 <meta http-equiv="Content-Language" content="en"/>
    8 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
    9 <meta name="Author" content="Stephane Micheloud"/>
   10 <style type="text/css">
   11   <!--
   12   blockquote, pre { margin:1em 4em 1em 4em; }
   13   dt { margin: 0.6em 0 0 0; }
   14   p { margin:0.6em 2em 0.6em 2em; text-align:justify; }
   15   //-->
   16 </style>
   17 </head>
   18 
   19 <body>
   20 <!-- header -->
   21 <div style="margin: 0 0 2em 0;">
   22 <div style="float:left;">
   23 scala(1)
   24 </div>
   25 <div style="float:right;">
   26 scala(1)
   27 </div>
   28 <div style="text-align:center;">
   29 USER COMMANDS
   30 </div>
   31 </div>
   32 
   33 <h3 id="name">NAME</h3>
   34 <p>
   35 <code><b>scala</b></code> &#8211; Run code in the <a href="https://scala-lang.org/">Scala 2</a> language</p>
   36 
   37 <h3 id="synopsis">SYNOPSIS</h3>
   38 <p>
   39 <code><b>scala</b></code><code>  [ &lt;<i>option</i>&gt; ]... [ &lt;<i>torun</i>&gt; &lt;<i>argument</i>&gt;... ]</code></p>
   40 
   41 <h3 id="parameters">PARAMETERS</h3>
   42 <p>
   43 <ins><dl>
   44 <dt>
   45 <code>&lt;<i>compiler-option</i>&gt;</code>
   46 </dt>
   47 <dd>
   48 Any scalac option.  See <a href="scalac.html"><b>scalac</b>(1)</a>.</dd>
   49 <dt>
   50 <code><b>&#8211;howtorun:</b>&lt;<i>how</i>&gt; </code>
   51 </dt>
   52 <dd>
   53 How to execute &lt;<i>torun</i>&gt;, if it is present. Options for &lt;<i>how</i>&gt; are <code>guess</code> (the default), <code>script</code>, <code>jar</code>, and <code>object</code>.</dd>
   54 <dt>
   55 <code><b>&#8211;i</b> &lt;<i>file</i>&gt; </code>
   56 </dt>
   57 <dd>
   58 Requests that a file be pre-loaded.  It is only meaningful for interactive shells.</dd>
   59 <dt>
   60 <code><b>&#8211;e</b> &lt;<i>string</i>&gt; </code>
   61 </dt>
   62 <dd>
   63 Requests that its argument be executed as Scala code.</dd>
   64 <dt>
   65 <code><b>&#8211;savecompiled</b> </code>
   66 </dt>
   67 <dd>
   68 Save this compiled version of scripts in order to speed up later executions of the same script.  When running a script, save the compiled version in a file with the same name as the script but with an extension of <code>.jar</code>.  On subsequent runs of the same script, the pre-compiled <code>.jar</code> file will be used if it is newer than the script file.</dd>
   69 <dt>
   70 <code><b>&#8211;nocompdaemon</b> </code>
   71 </dt>
   72 <dd>
   73 Do not use the <code><b>fsc</b></code> offline compiler.</dd>
   74 <dt>
   75 <code><b>&#8211;nc</b> </code>
   76 </dt>
   77 <dd>
   78 Same as <code>-nocompdaemon</code>.</dd>
   79 <dt>
   80 <code><b>&#8211;D</b>property=value </code>
   81 </dt>
   82 <dd>
   83 Set a Java system property.  If no value is specified, then the property is set to the empty string.</dd>
   84 <dt>
   85 <code>&lt;<i>torun</i>&gt;</code>
   86 </dt>
   87 <dd>
   88 A top-level object or a script file to run.</dd>
   89 <dt>
   90 <code>&lt;<i>argument</i>&gt;</code>
   91 </dt>
   92 <dd>
   93 An arguments to pass to &lt;<i>torun</i>&gt;.</dd>
   94 </dl></ins>
   95 </p>
   96 
   97 <h3 id="description">DESCRIPTION</h3>
   98 <p>
   99 The <code><b>scala</b></code> utility runs Scala code using a Java runtime environment.  The Scala code to run is specified in one of three ways:</p>
  100 <ol>
  101 <li>With no arguments specified, a Scala shell starts and reads commands interactively.<li>With <code>-howtorun:object</code> specified, the fully qualified name of a top-level Scala object may be specified.  The object should previously have been compiled using <a href="scalac.html"><b>scalac</b>(1)</a>.<li>With <code>-howtorun:script</code> specified, a file containing Scala code may be specified.</ol>
  102 <p>
  103 If <code>-howtorun:</code> is left as the default (<code>guess</code>), then the <code><b>scala</b></code> command will check whether a file of the specified name exists.  If it does, then it will treat it as a script file; if it does not, then it will treat it as the name of an object.</p>
  104 <p>
  105 In all three cases, arbitrary scalac options may be specified. The most common option is to specify a classpath with <code>-classpath</code>, but see the <a href="scalac.html"><b>scalac</b>(1)</a> page for full details.   </p>
  106 <p>
  107 If an object is specified to run, then that object must be a top-level Scala object with the specified name.  The object must define a method <b>main</b> with the following signature:</p>
  108 <blockquote><p>
  109 <code><b>def</b> main(args: Array[String]): Unit</code></p></blockquote>
  110 <p>
  111 The method must return a <b>Unit</b> value, and it must accept a <b>String</b> array as a parameter.  All arguments specified on the command line will be passed as arguments to the <b>main</b> method.</p>
  112 <p>
  113 If a script file is specified to run, then the file is read and all Scala statements and declarations in the file are processed in order. Any arguments specified will be available via the <code>args</code>variable.</p>
  114 <p>
  115 Script files may have an optional header that is ignored if present.  There are two ways to format the header: either beginning with <code>#!</code> and ending with <code>!#</code>, or beginning with <code>::#!</code> and ending with <code>::!#</code>.</p>
  116 <p>
  117 Such a header must have each header boundary start at the beginning of a line.  Headers can be used to make stand-alone script files, as shown in the examples below.</p>
  118 <p>
  119 When running a script or using <code>-e</code>, an already running compilation daemon (fsc) is used, or a new one started on demand.  The <code>-nocompdaemon</code> or <code>-nc</code> option can be used to prevent this.</p>
  120 <p>
  121 If no -classpath option is specified, then <code>scala</code> will add ".", the current directory, to the end of the classpath.</p>
  122 
  123 <h3 id="options">OPTIONS</h3>
  124 <p>
  125 If any compiler options are specified, they must be first in the command line and must be followed by a bare hyphen ("-") character. If no arguments are specified after the optional compiler arguments, then an interactive Scala shell is started.  Otherwise, either a script file is run, or a pre-compiled Scala object is run.  It is possible to distinguish the last two cases by using an explicit <code>-object</code> or <code>-script</code> flag, but usually the program can guess correctly.</p>
  126 
  127 <h3 id="environment">ENVIRONMENT</h3>
  128 <p>
  129 <ins><dl>
  130 <dt>
  131 <code><b>JAVACMD</b></code>
  132 </dt>
  133 <dd>
  134 Specify the <code><b>java</b></code> command to be used for running the Scala code.  Arguments may be specified as part of the environment variable; spaces, quotation marks, etc., will be passed directly to the shell for expansion.</dd>
  135 <dt>
  136 <code><b>JAVA_HOME</b></code>
  137 </dt>
  138 <dd>
  139 Specify JDK/JRE home directory. This directory is used to locate the <code><b>java</b></code> command unless <code><b>JAVACMD</b></code> variable set.</dd>
  140 <dt>
  141 <code><b>JAVA_OPTS</b></code>
  142 </dt>
  143 <dd>
  144 <div>
  145 Specify the options to be passed to the <code><b>java</b></code> command defined by <code><b>JAVACMD</b></code>.
  146 </div>
  147 <div>
  148 One might for example configure the memory usage of the JVM with: <code>JAVA_OPTS="-Xmx2G -Xss16M"</code>
  149 </div>
  150 </dd>
  151 </dl></ins>
  152 </p>
  153 
  154 <h3 id="examples">EXAMPLES</h3>
  155 <p>
  156 Here are some examples of running Scala code:</p>
  157 <p>
  158 <ins><dl>
  159 <dt>
  160 Execute a Scala program generated in the current directory
  161 </dt>
  162 <dd>
  163 <code><b>scala</b></code><code> hello.HelloWorld</code></dd>
  164 <dt>
  165 Execute a Scala program generated in a user-defined directory <b>classes</b>
  166 </dt>
  167 <dd>
  168 <code><b>scala</b></code><code> <code><b>&#8211;classpath</b> classes </code>hello.HelloWorld</code></dd>
  169 <dt>
  170 Execute a Scala program using a user-defined <code><b>java</b></code> command
  171 </dt>
  172 <dd>
  173 <code><b>env JAVACMD</b></code><code>=/usr/local/bin/cacao </code><code><b>scala</b></code><code> <code><b>&#8211;classpath</b> classes </code>hello.HelloWorld</code></dd>
  174 <dt>
  175 Execute a Scala program using JVM options
  176 </dt>
  177 <dd>
  178 <code><b>env JAVACMD</b></code><code>=java </code><code><b>JAVA_OPTS</b></code><code>="-Dmsg=hello -enableassertions" </code><code><b>scala</b></code><code> <code><b>&#8211;classpath</b> classes </code>hello.HelloWorld</code></dd>
  179 </dl></ins>
  180 </p>
  181 <p>
  182 Here is a complete Scala script for Unix: </p>
  183 <pre>#!/bin/sh
  184 exec scala "$0" "$@"
  185 !#
  186 Console.println("Hello, world!")
  187 args.toList foreach Console.println</pre>
  188 <p>
  189 Here is a complete Scala script for MS Windows: </p>
  190 <pre>::#!
  191 @echo off
  192 call scala %0 %*
  193 goto :eof
  194 ::!#
  195 Console.println("Hello, world!")
  196 args.toList foreach Console.println</pre>
  197 <p>
  198 If you want to use the compilation cache to speed up multiple executions of the script, then add <code>-savecompiled</code> to the scala command:</p>
  199 <pre>#!/bin/sh
  200 exec scala -savecompiled "$0" "$@"
  201 !#
  202 Console.println("Hello, world!")
  203 args.toList foreach Console.println</pre>
  204 
  205 <h3 id="exit_status">EXIT STATUS</h3>
  206 <p>
  207 The <code><b>scala</b></code> command returns a zero exit status if it succeeds. Non zero is returned in case of any error.  If a script or top-level object is executed and returns a value, then that return value is passed on to <code><b>scala</b></code>.</p>
  208 
  209 <h3 id="author">AUTHOR</h3>
  210 <p>
  211 Written by Martin Odersky and other members of the <a href="https://www.scala-lang.org/news/2014/01/22/10-years-of-scala.html">Scala team</a>.</p>
  212 
  213 <h3 id="reporting_bugs">REPORTING BUGS</h3>
  214 <p>
  215 Report bugs to <code>https://github.com/scala/bug/issues</code>.</p>
  216 
  217 <h3 id="copyright">COPYRIGHT</h3>
  218 <p>
  219 This is open-source software, available to you under the Apache License 2.0. See accompanying "copyright" or "LICENSE" file for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.</p>
  220 
  221 <h3 id="see_also">SEE ALSO</h3>
  222 <p>
  223 <a href="fsc.html"><b>fsc</b>(1)</a>, <a href="scalac.html"><b>scalac</b>(1)</a>, <a href="scaladoc.html"><b>scaladoc</b>(1)</a>, <a href="scalap.html"><b>scalap</b>(1)</a></p>
  224 <!-- footer -->
  225 <div style="margin: 2em 0 0 0;">
  226 <div style="float:left;">
  227 version 0.5
  228 </div>
  229 <div style="float:right;">
  230 scala(1)
  231 </div>
  232 <div style="text-align:center;">
  233 April 2007
  234 </div>
  235 </div>
  236 </body>
  237 </html>