Audience
The following instruction is for Mac OS machines only. If you are using linux or WSL, see me.
Background
An alias is a name one creates to be equivalent to a long command line command to save typing at the terminal. The version of Kotlin we are using relies on the JVM, and thus ultimately on the class files for the standard Java library and the Kotlin runtime library. The Processing libraries relies on the class files containing those libraries. When we program in Kotlin using the Processing libraries, we need to issue commands to tell the Java compiler and Java interpreter about where to find these class files. The information to be provided is rather long, and we don’t want to type it in every time when we compile & run our Kotlin programs. This is where aliases come in.
Necessary Preparation
Before you can create aliases, make sure you have installed Processing 4 on your machine. The software is available from https://processing.org/download. After installation, you should add the Minim library to Processing as well.
Doing it
You’ll have to edit 3 files.
- Using your text editor, edit the file
~/.aliases(or create the file if it does not exist) and add all content of this file to it. Using your text editor, edit the file
~/.zshenv(or create the file if it doesn’t exist) and add the following lines############################################### # One of the followings gets added to ~/.zshenv ############################################### # if using brew's kotlin export KOTLIN_VERSION=$(ls /usr/local/Cellar/kotlin) export KOTLIN_HOME=/usr/local/Cellar/kotlin/$KOTLIN_VERSION/libexec # if using sdkman's kotlin export KOTLIN_HOME=$HOME/.sdkman/candidates/kotlin/currentUsing your text editor, edit the file
~/.zshrc(or create the file if it doesn’t exist) and add the following lines####################################### # The following gets added to ~/.zshrc ####################################### source ~/.aliasesTo make all these definitions available to the shell, logout and relogin. You should try to make sure that after relogin, you can execute your new aliases. First, using your text editor, create a program in kotlin using processing, say,
MondrianBasic.kt. Now compile the file by typing% pktc MondrianBasic.ktand typing
% pkt MondrianBasicKtto run the resulting
MondrianBasicKt.classfile.