How To Create Julia Apps

Recently I wrote about how to create julia packages. I create a small julia app to create the data for the QR decomposition evaluation. I encountered a few steps where I had to google how to resolve them. Therefore, I thought I could just as well write them down here.

First of all, creating a julia app is not that much different from creating a julia package and the relevant official documentation is located here and here. I also found the hints in this discourse thread as well as this discourse thread to be helpful. The latter two links tell you how to launch a project and selecting the correct environment and how to use packages that do not come as official julia packages or which might not be stored in a git repository.

Step By Step Guide

Let’s create a simple hello world app. To this end create a folder named hello_world and launch julia from within it. If you enter pwd() in julia, you should get the path to your hello_world folder.

Now switch to pkg mode by entering ] and enter

activate .

You should notice that you prompt has changed and that in now contains hello_world. Now let’s say we use the LinearAlgebra package. We would add it as a dependency by entering (still in pkg mode):

add LinearAlgebra

If you look into your hello_world folder, you’ll notice that there’s a Manifest.toml and Project.toml file now. Now let’s create a /src/main.jl file with the following content:

import LinearAlgebra

println("Hello World!")

From your command line (bash, zsh, fish, …) you can then execute your code by entering

julia --project=. src/main.jl

You should now see the greeting on your command line.

Custom Package Dependencies

If you have packages sitting in some folder on your computer and which are not managed by the julia registry, then you can still use them in your project but you need to enter the following on the julia prompt (while your project is active):

using Pkg

This will add the necessary dependencies in your project configuration.

Using Other Peoples Apps

If you want to use an app that somebody else has written, then simply get their code, launch julia in the respective folder and enter the following commands in pkg mode:

activate .

The second command makes sure that all dependencies are properly installed.

Mathematician and
Software Engineer

Researcher, Engineer, Tinkerer, Scholar, Philosopher, and Hyrox afficionado