2
2
3
3
Every Kotlin release ships with a standalone version of the compiler. You can download the latest version manually or via a package manager.
4
4
5
- > Installing the command-line compiler is not an essential step to use Kotlin. A general way to write Kotlin applications is using an
6
- > IDE - [ IntelliJ IDEA] ( https://www.jetbrains.com/idea/ ) or [ Android Studio] ( https://developer.android.com/studio ) .
7
- > They provide full Kotlin support out of the box without needing additional components. Learn how to
8
- [ get started with Kotlin in an IDE] ( getting-started.md ) .
5
+ > Installing the command-line compiler is not an essential step to use Kotlin.
6
+ > The common approach is to write Kotlin applications using IDEs or code editors with official Kotlin support,
7
+ > such as [ IntelliJ IDEA] ( https://www.jetbrains.com/idea/ ) , [ JetBrains Fleet] ( https://www.jetbrains.com/fleet/ ) ,
8
+ > or [ Android Studio] ( https://developer.android.com/studio ) .
9
+ > They provide full Kotlin support right out of the box, no extra components needed.
10
+ >
11
+ > Learn how to [ get started with Kotlin in an IDE] ( getting-started.md ) .
9
12
>
10
13
{type="note"}
11
14
@@ -19,7 +22,7 @@ To install the Kotlin compiler manually:
19
22
2 . Unzip the standalone compiler into a directory and optionally add the ` bin ` directory to the system path.
20
23
The ` bin ` directory contains the scripts needed to compile and run Kotlin on Windows, macOS, and Linux.
21
24
22
- > For Windows users who want to use the command-line compiler, we recommend using the manual installation method .
25
+ > If you want to use the Kotlin command-line compiler on Windows , we recommend installing it manually .
23
26
>
24
27
{type="note"}
25
28
@@ -53,8 +56,8 @@ sudo snap install --classic kotlin
53
56
54
57
## Create and run an application
55
58
56
- 1 . Create a simple application in Kotlin that displays ` "Hello, World!" ` . In your favorite editor, create a new file called
57
- ` hello.kt ` with the following lines :
59
+ 1 . Create a simple console JVM application in Kotlin that displays ` "Hello, World!" ` .
60
+ In a code editor, create a new file called ` hello.kt ` with the following code :
58
61
59
62
``` kotlin
60
63
fun main () {
@@ -68,33 +71,33 @@ sudo snap install --classic kotlin
68
71
kotlinc hello.kt -include-runtime -d hello.jar
69
72
```
70
73
71
- The ` -d ` option indicates the output path for generated class files, which may be either a directory or a * .jar* file.
72
- The ` -include-runtime ` option makes the resulting * .jar* file self-contained and runnable by including the Kotlin runtime
74
+ * The ` -d ` option indicates the output path for generated class files, which may be either a directory or a ** .jar* * file.
75
+ * The ` -include-runtime ` option makes the resulting ** .jar* * file self-contained and runnable by including the Kotlin runtime
73
76
library in it.
74
77
75
- To see all available options, run
78
+ To see all available options, run:
76
79
77
80
``` bash
78
81
kotlinc -help
79
82
```
80
83
81
- 3 . Run the application.
84
+ 3 . Run the application:
82
85
83
86
``` bash
84
87
java -jar hello.jar
85
88
```
86
89
87
90
## Compile a library
88
91
89
- If you're developing a library to be used by other Kotlin applications, you can build the * .jar* file without including
90
- the Kotlin runtime in it :
92
+ If you're developing a library to be used by other Kotlin applications, you can build the ** .jar* * file without including
93
+ the Kotlin runtime:
91
94
92
95
``` bash
93
96
kotlinc hello.kt -d hello.jar
94
97
```
95
98
96
- Since binaries compiled this way depend on the Kotlin runtime, you should make sure the latter is present in the classpath
97
- whenever your compiled library is used.
99
+ Since binaries compiled this way depend on the Kotlin runtime,
100
+ you should ensure that it is present in the classpath whenever your compiled library is used
98
101
99
102
You can also use the ` kotlin ` script to run binaries produced by the Kotlin compiler:
100
103
@@ -113,7 +116,8 @@ and see the results.
113
116
114
117
## Run scripts
115
118
116
- Kotlin can also be used as a scripting language. A script is a Kotlin source file (` .kts ` ) with top-level executable code.
119
+ You can use Kotlin as a scripting language.
120
+ A Kotlin script is a Kotlin source file (` .kts ` ) with top-level executable code.
117
121
118
122
``` kotlin
119
123
import java.io.File
@@ -133,9 +137,10 @@ kotlinc -script list_folders.kts -- -d <path_to_folder_to_inspect>
133
137
```
134
138
135
139
Kotlin provides experimental support for script customization, such as adding external properties,
136
- providing static or dynamic dependencies, and so on. Customizations are defined by so-called * Script definitions* -
137
- annotated kotlin classes with the appropriate support code. The script filename extension is used to select the appropriate
138
- definition. Learn more about [ Kotlin custom scripting] ( custom-script-deps-tutorial.md ) .
140
+ providing static or dynamic dependencies, and so on.
141
+ Customizations are defined by so-called _ script definitions_ – annotated kotlin classes with the appropriate support code.
142
+ The script filename extension is used to select the appropriate definition.
143
+ Learn more about [ Kotlin custom scripting] ( custom-script-deps-tutorial.md ) .
139
144
140
145
Properly prepared script definitions are detected and applied automatically when the appropriate jars are included
141
146
in the compilation classpath. Alternatively, you can specify definitions manually by passing the ` -script-templates ` option
@@ -145,4 +150,4 @@ to the compiler:
145
150
kotlinc -script-templates org.example.CustomScriptDefinition -script custom.script1.kts
146
151
```
147
152
148
- For additional details, please consult the [ KEEP-75] ( https://github.com/Kotlin/KEEP/blob/master/proposals/scripting-support.md ) .
153
+ For additional details, see the [ KEEP-75] ( https://github.com/Kotlin/KEEP/blob/master/proposals/scripting-support.md ) .
0 commit comments