Starting a Julia notebook

A Julia notebook is a system that combines mathematical text, executable Julia code, and graphical output within a web browser. If you have Julia running on a laptop or UNH computer, you can start a notebook as follows

Note: you will have to do all these steps only the first time you run a Julia notebook. After that you can just start with step 5, using IJulia.

1. Download a Julia notebook file to your computer. Let's start with notebooks from David Sanders' Hands-on Julia tutorial. You can download them from the previous link or get them here:

2. Start the Julia REPL by clicking the executable or directly from the command line.

               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.4.6 (2016-06-19 17:16 UTC)
 _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
|__/                   |  x86_64-unknown-linux-gnu

julia> 

3. At the Julia prompt, type Pkg.add(“IJulia”). This tells Julia to download and install the IJulia notebook software onto the computer.

julia> Pkg.add("IJulia")
INFO: Nothing to be done                                                                        
INFO: METADATA is out-of-date — you may not have the latest version of IJulia                   
INFO: Use `Pkg.update()` to get the latest versions of your packages                            
julia>

4. At the Julia prompt, type Pkg.update(). This tells Julia to download and install any required software updates. This might take a while and print out lots of download & install information.

julia> Pkg.update()
INFO: Updating METADATA...
INFO: Updating cache of ColorTypes...
INFO: Updating cache of BinDeps...
INFO: Updating cache of ZMQ...
INFO: Updating cache of IJulia...
INFO: Updating cache of URIParser...
INFO: Updating cache of Conda...
INFO: Updating cache of HttpCommon...
....and many more such messages...

julia>

5. At the Julia prompt, type using IJulia. This tells Julia to load the IJulia module into your active Julia session.

julia> using IJulia
INFO: Recompiling stale cache file /home/gibson/.julia/lib/v0.4/IJulia.ji for module IJulia.
INFO: Recompiling stale cache file /home/gibson/.julia/lib/v0.4/ZMQ.ji for module ZMQ.
INFO: Recompiling stale cache file /home/gibson/.julia/lib/v0.4/Nettle.ji for module Nettle.

julia> 

6. At the Julia prompt, type notebook(dir=homedir()). This tells Julia to start an IJulia notebook in a browser, either starting up a new browser, if you don't have one running, or as a new tab in an existing browser. The dir=homedir() argument tells Julia to start the notebook in your home directory (folder), rather than

julia> notebook(dir=homedir())

You should be able to naviagate to wherever you downloaded the Julia notebook file. The browser window will look somethign like this, listing the Julia notebooks you downloaded.

6. Click on “Numbers, variables, and basic functions.ipynb” in the browser. That'll start the interactive Julia notebook session.

7. At this point you can click on and modify anything in the Julia notebook. Try clicking on the line that read typeof(10) and then hitting “shift-return” or “shift-enter” to execute the typeof(10) statement. i.e. to make Julia evaluate the expression typeof(10) and respond with the result.