|
1 | 1 | [//]: # (title: Get started with Kotlin/Native using the command-line compiler)
|
2 | 2 |
|
3 |
| -## Obtain the compiler |
| 3 | +## Download and install the compiler |
4 | 4 |
|
5 |
| -The Kotlin/Native compiler is available for macOS, Linux, and Windows. It is available as a command line tool and ships |
6 |
| -as part of the standard Kotlin distribution and can be downloaded from [GitHub Releases](%kotlinLatestUrl%). It supports |
7 |
| -different targets including Linux, macOS, iOS, and others. [See the full list of supported targets](native-target-support.md). |
| 5 | +The Kotlin/Native compiler works on macOS, Linux, and Windows. It's available as a command line tool and ships |
| 6 | +as part of the standard Kotlin distribution. You can download it from our [GitHub Releases](%kotlinLatestUrl%) page. |
| 7 | + |
| 8 | +The compiler supports different targets including Linux, macOS, iOS, and others. [See the full list of supported targets](native-target-support.md). |
8 | 9 | While cross-platform compilation is possible, which means using one platform to compile for a different one,
|
9 |
| -in this %product% case we'll be targeting the same platform we're compiling on. |
| 10 | +in this case, you'll be targeting the same platform you're compiling on. |
10 | 11 |
|
11 |
| -While the output of the compiler does not have any dependencies or virtual machine requirements, |
12 |
| -the compiler itself requires [Java 1.8 or higher runtime](https://jdk.java.net/11/). |
| 12 | +> Although the output of the compiler doesn't have any dependencies or virtual machine requirements, the compiler itself |
| 13 | +> requires Java 1.8 or higher runtime. It's supported by [JDK 8 (JAVA SE 8) or later versions](https://www.oracle.com/java/technologies/downloads/). |
| 14 | +> |
| 15 | +{type="note"} |
13 | 16 |
|
14 |
| -Install the compiler by unpacking its archive to a directory of your choice and adding the path to its `/bin` directory |
| 17 | +To install the compiler, unpack its archive to a directory of your choice and add the path to its `/bin` directory |
15 | 18 | to the `PATH` environment variable.
|
16 | 19 |
|
17 |
| -## Write "Hello Kotlin/Native" program |
| 20 | +## Write "Hello, Kotlin/Native" program |
18 | 21 |
|
19 |
| -The application will print "Hello Kotlin/Native" on the standard output. In a working directory of choice, create a file named |
20 |
| -`hello.kt` and enter the following contents: |
| 22 | +The application will print "Hello, Kotlin/Native" on the standard output. |
| 23 | +Choose a working directory and create a file there named `hello.kt`. Update it with the following code: |
21 | 24 |
|
22 | 25 | ```kotlin
|
23 | 26 | fun main() {
|
24 |
| - println("Hello Kotlin/Native!") |
| 27 | + println("Hello, Kotlin/Native!") |
25 | 28 | }
|
26 | 29 | ```
|
27 | 30 |
|
28 | 31 | ## Compile the code from the console
|
29 | 32 |
|
30 |
| -To compile the application use the [downloaded](https://github.com/JetBrains/kotlin/releases) |
31 |
| -compiler to execute the following command: |
| 33 | +To compile the application, execute the following command with the [downloaded](https://github.com/JetBrains/kotlin/releases) |
| 34 | +compiler: |
32 | 35 |
|
33 | 36 | ```bash
|
34 | 37 | kotlinc-native hello.kt -o hello
|
35 | 38 | ```
|
36 | 39 |
|
37 | 40 | The value of `-o` option specifies the name of the output file, so this call should generate a `hello.kexe` (Linux and macOS)
|
38 |
| -or `hello.exe` (Windows) binary file. |
39 |
| -For the full list of available compiler options, see the [compiler options reference](compiler-reference.md). |
| 41 | +or `hello.exe` (Windows) binary file. For the full list of available options, see [Kotlin compiler options](compiler-reference.md). |
40 | 42 |
|
41 | 43 | While compilation from the console seems to be easy and clear, it
|
42 |
| -does not scale well for larger projects with hundreds of files and libraries. For real-world projects, it is recommended |
43 |
| -to use a [build system](native-gradle.md) and [IDE](native-get-started.md). |
| 44 | +doesn't scale well for larger projects with hundreds of files and libraries. For real-world projects, it is recommended |
| 45 | +to use a [build system](native-gradle.md) and an [IDE](native-get-started.md). |
| 46 | + |
| 47 | +## Run the program |
| 48 | + |
| 49 | +To run the program, in your command line tool, navigate to the directory containing the `hello.kexe` (or `hello.exe`) file |
| 50 | +and run the `./hello.kexe` (or `./hello.exe`) command. The application should print "Hello, Kotlin/Native" on the standard output. |
0 commit comments