Programming Kotlin Applications. Бретт Мак-Лахлин
Чтение книги онлайн.

Читать онлайн книгу Programming Kotlin Applications - Бретт Мак-Лахлин страница 11

Название: Programming Kotlin Applications

Автор: Бретт Мак-Лахлин

Издательство: John Wiley & Sons Limited

Жанр: Программы

Серия:

isbn: 9781119696216

isbn:

СКАЧАТЬ target="_blank" rel="nofollow" href="#ulink_426b5317-c020-57a3-98f0-5c8a3d1f26e1">FIGURE 1.2 IntelliJ comes prepackaged with a system-specific installation process.

      NOTE The “installation process” for IntelliJ on Mac OS X is pretty simple: just drag the package (presented as an icon) into your Applications folder. You'll then need to go to that folder and launch IntelliJ or drag the icon into your Dock, which is what I've done.

       For Windows, you download the executable and run it. You can then create a shortcut on your desktop if you like.

       In both cases, you can use the JetBrains Toolbox (which comes with the JetBrains Kotlin package) to keep your installation current and add updates when they're available.

      WARNING You may need advanced permissions to install the Launcher Script that IntelliJ creates if you accepted the default location on Mac OS X.

Snapshot of IntelliJ makes getting going in Kotlin simple and prompts you on creating a new project to include Kotlin libraries.

      Create Your Kotlin Program

      NOTE Your IDE may not be configured exactly like mine. If you don't see the src/ folder, you may need to click Project on the left side of your IDE to display the various folders, and possibly click again on the name of the project.

Snapshot of Kotlin code should go in the src/ folder.

      NOTE From this point forward, code will typically not be shown in an IDE. That way, you can use the IDE of your choice (or the command line), because you should get the same results across IDEs.

Snapshot of IntelliJ automatically formats code and adds sensible syntax highlighting.

      Compile and Run Your Kotlin Program

Snapshot of the empty output of your program displaying in its own window.

      In this case, you shouldn't get any errors, but there's not any output either. We'll fix that shortly.

      Fix Any Errors as They Appear

      You can then easily fix the error and rebuild.

      Install Kotlin (and Use the Command Line)

      For power users, there's a tendency to want to use the command line for nearly everything. Kotlin is no exception. Because it's “mostly Java” in the sense that it runs using a JVM and JDK, you can get pretty far without a lot of work.

      Command-Line Kotlin on Windows

      For Windows users, you'll first need a JDK. You can download one from the Oracle Java download page at www.oracle.com/technetwork/java/javase/downloads. That download has version-specific instructions that are easy to follow.