Installfest

Requirements

In order to run Clojure and the tools we'll be using for programming we need to install some free software on your laptop. Most modern laptops should work just fine. Just to be sure the requirements for each operating system are...

If you don't have access to a laptop or your laptop doesn't meet the requirements above we have a few spare laptops that you can borrow.

By the end of these instructions, you will have the following installed:

And you will have:

Instructions for all

These instructions apply to all platforms: Mac, Windows and Linux:

Instructions by operating system

Choose your operating system to get setup instructions:

Slack

Request an invitation to Clojurians Slack

In a web browser go to http://clojurians.net/ and enter your e-mail address to get an invitation.

request invitation

Click on the link from your e-mail and register

Check your e-mail for the message from Slack and click the link to complete your registration:

register

Sign in to Slack

Sign in to Slack and click on "Explore Slack".

sign-in

Join the #clojurebridgemn channel

Now in the upper right search box enter #clojurebridgemn -- this is the channel for ClojureBridgeMN students and volunteers. When you see the channel listed in search results.. click on it. Then click the Join button at the bottom of the page.

Now you ask questions and get answers right away (even after the workshop)!

This is the Slack for the Clojure Community -- there are channels for every possible topic, from core development, specific applications and even user groups in geographic locations (for example our own Clojure.MN user's group is on #clojuremn)

Atom

Install the Atom Editor

Go to https://atom.io to download and install the Atom editor for your computer.

Github

Setup at a Github account

You will use Github to publish your application program.

The first setup is setting up a github account.

At your leisure you can visit the about your profile to learn more about github and how to customize your profile.

Extra credit: setting up ssh

Whenever you upload anything (like a change to your program) to github it will need to know your username and password. Entering these credentials every time can quickly become tedious.

The way to simplify the process is to create an ssh key pair (ssh stands for secure shell). When you create your own ssh key pair there is a private key (which is only ever on your computer) and a public key (that you can share with any site that needs to know your credentials).

Once you set this up and provide your private ssh key password on your computer the first time you won't have to enter any passwords every time you want git push something to github.

See the detailed documentation on getting ssh setup for github.

Windows users may want to try Git Bash as way of interacting with git and github.

OS X Setup

Starting a terminal

For these instructions, and for much of the class, you will need to have a terminal, or command line, open. This is a text-based interface to talk to your computer, and you can open it by running Terminal.app, which is found under /Applications/Utilities. If you have never used the terminal before, you may want to spend some time reading up on command-line basics.

Go ahead and open your terminal now. It should look something like this:

blank terminal

The prompt (where you will type your commands) may look different: it usually shows the computer name and user name, as well as the folder or directory you are currently in.

For the rest of this setup, I will tell you to run commands in your terminal. When I say that, I mean "type the command into the terminal and press the Return key."

Making sure Java is installed

Run java -version in your terminal.

If Java is installed, you will see something like this in your terminal:

Java version

If Java is not installed, or the version number is less than 1.8 you can download it here Java Downloads

Java download 1

Click the Java download button.

Java download 2

Accept the license agreement, and download the version for Mac OS X.

Double-click the jdk-8u111-macosx-x64.dmg file in your Downloads directory and walk through the installer.

Java download 1

Installing Leiningen

Leiningen is a tool used on the command line to manage Clojure projects.

To install lein, execute the following commands in your terminal. You will be prompted to enter your password.

curl https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein > lein
sudo mkdir -p /usr/local/bin/
sudo mv lein /usr/local/bin/lein
sudo chmod a+x /usr/local/bin/lein
cd $HOME
echo 'PATH=$PATH:/usr/local/bin' >> .bashrc
source .bashrc

After you run the above commands, run the lein version command. It should take a while to run, as it will download some resources it needs the first time. If it completes successfully, you are golden! If not, ask an instructor for help.

Getting setup with Heroku

Heroku is the tool we will use in order to put your application online where others can see it.

First, we need to create an account. Go to Heroku and click the "Sign up" link.

Heroku step 1

You will be taken to a form where you can create an account. Fill out that form, and you will be sent an email with a link to click to continue the signup process.

Heroku step 2

After clicking on the link, you will be taken to another form where you will need to choose a password. Choose one and enter it twice.

Heroku step 3

After all that, go here and download the installer.

Heroku dashboard

If you do not see this link, you can download the toolbelt from toolbelt.heroku.com.

This will download a .pkg file. Double-click it to install the Heroku Toolbelt and follow all prompts from the installation wizard. You will need your OS X account password to complete installation. If you are prompted to create an SSH key, say yes. It may also prompt you to install git. Once the Heroku Toolbelt is installed, go to your terminal and run the command heroku login. You will be prompted for your email and password on Heroku. If you enter them and the command ends successfully, congratulations!

Testing your setup

You have set up Java, Leiningen, Atom, Git, and Heroku on your computer--all the tools you will need for this course. Before starting, we need to test them out.

Go to your terminal and run the following command:

git clone https://github.com/heroku/clojure-sample.git

This will check out a sample Clojure application from GitHub, a central repository for lots of source code. Your terminal should look similar to this picture:

Testing git clone

Then run the command:

cd clojure-sample

This will put you in the directory with the source code for this sample bit of Clojure code. After that completes, run:

lein repl

This could take a long time, and will download many other pieces of code it relies on. You should see lines that start with Retrieving ... on your screen. When it finishes, your terminal should look like the following:

Testing lein repl

This is starting a REPL, which we will learn about soon. It's a special terminal for Clojure. At the REPL prompt, type (+ 1 1) and press Return. Did you get the answer 2 back? You will learn more about that in the course.

For now, enter (quit) to quit the REPL. (NOTE: you can also type (exit) or press the Control button and D button on your keyboard together). This should take you out of the Clojure REPL and back to your normal terminal prompt.

You should still be in the clojure-sample directory.

Run this command:

heroku create

There should be output about something being created. A URL will be displayed. Look at the following example:

Testing heroku create

Next, run the following commands:

git push heroku master
heroku open

Enter "yes" if you are asked if you are sure you want to connect, like in the following image:

Connecting via SSH

Your browser should open (and take a long time to load), and you should see a website like the following:

Testing heroku working

If your browser does not open after running

heroku open

start a browser and go to the URL displayed after you ran

heroku create

Congratulations! That website is running code you have on your computer that you have uploaded. You have actually made a very simple Clojure app, and your computer is all set up to make more.

Windows 7 Setup

Starting a command prompt

For these instructions, and for much of the class, you will need to have a command prompt open. This is a text-based interface to talk to your computer. Go to the Start Menu and type "command" in the search box. Choose the "Command Prompt" program, like in this screenshot:

Starting a command prompt

When you choose "Command Prompt," your screen should look similar to this:

Command prompt

If you have never used the command prompt before, you may want to spend some time reading up on command prompt basics. For the rest of this setup, I will tell you to run commands in your command prompt. When I say that, I mean "type the command into the command prompt and press the Return key."

On other operating systems, the command prompt is called the terminal. We will use the terms terminal, command prompt, and command line interchangably.

Installing Java

Go to Oracle website. Then, you should see a screen like the following:

First page of Java download

Click the button above "Java Platform (JDK)," as you can see in the above picture. Then you will come to a page that will have the following table on it:

Second page of Java download

Click the radio button to accept the license agreement, and then download one of the two Windows choices. If you are running 32-bit Windows, choose "Windows x86." If you are running 64-bit Windows, choose "Windows x64."

If you do not know if you are running 32-bit or 64-bit Windows, go to the Control Panel (Start Menu - Control Panel) and choose "System and Security" and then "System." You should see a window like the following:

Windows My Computer properties

You should see if you are running 32- or 64-bit Windows beside "System Type."

Once you have downloaded the right Java version, run the executable you downloaded to install Java. Follow the installation wizard.

Installing Leiningen

Leiningen is a tool used on the command line to manage Clojure projects.

Next, go to the Leiningen Windows installer site and download the file linked as "leiningen-win-installer." Run this executable and follow the "Detailed installation" section at the Leiningen Windows Installer site. At the end of the installation, leave "Run a Clojure REPL" checked before you click "Finish." If a terminal window opens that looks like the one on the Leiningen Windows installer site, then you are good to go.

Get setup with Heroku

Heroku is the tool we will use in order to put your application online where others can see it.

First, we need to create an account. Go to Heroku and click the "Sign up" link.

Heroku step 1

You will be taken to a form where you need to enter your email address in order to sign up. Fill out that form, and you will be sent an email with a link to click to continue the signup process.

Heroku step 2

After clicking on the link, you will be directed to check your email for a comfirmation messages.

Heroku step 2

An email from Heroku will contain a link to click which will confirm that the new account is connected to a valid email address.

Heroku step 2

After clicking on the link in the email, you will be taken to another form where you will need to choose a password. Choose one and enter it twice.

Heroku step 3

After all that, go here and download the installer appropriate for you system (probably 64-bit).

Heroku dashboard

If you do not see this link on your dashboard, you can download the toolbelt from toolbelt.heroku.com.

You will download an .exe file. Run this executable to install the Heroku Toolbelt and follow all prompts from the installation wizard.

Now you can login to heroku the first time:

clojurista@mylaptop$ heroku login
Enter your Heroku credentials.
Email: clojurista@gmail.com
Password (typing will be hidden): ++++++++
Logged in as clojurista@gmail.com
clojurista@mylaptop$

Testing your setup

You have set up Java, Leiningen, Atom, Git, and Heroku on your computer, all the tools you will need for this program. Before starting, we need to test them out. Make sure you have a terminal (OS X) or command prompt (Windows) open for testing. We will just call this a terminal from now on.

Go to your terminal and run the following command:

git clone https://github.com/heroku/clojure-sample.git

This will check out a sample Clojure application from GitHub, a central repository for lots of source code. Your terminal should look similar to this picture:

Testing git clone

Then run the command:

cd clojure-sample

This will put you in the directory with the source code for this sample bit of Clojure code. After that completes, run:

lein repl

This could take a long time, and will download many other pieces of code it relies on. You should see lines that start with Retrieving ... on your screen. When it finishes, your terminal should look like the following:

Testing lein repl

This is starting a REPL, which we will learn about soon. It's a special terminal for Clojure. At the REPL prompt, type (+ 1 1) and hit enter. Did you get the answer 2 back? You will learn more about that in the course.

For now, enter (quit) to quit the REPL. (NOTE: you can also type (exit) or press the Control button and D button on your keyboard together). This should take you out of the Clojure REPL and back to your normal terminal prompt.

We only have one more thing to test, Heroku.

Go back to your terminal. You should still be in the clojure-sample directory.

Run this command:

heroku create

There should be output about something being created. A URL will be displayed. Look at the following example:

Testing heroku create

Next, run the following commands:

git push heroku master

heroku open

Enter "yes" if you are asked if you are sure you want to connect.

Your browser should open (and take a long time to load) and you should see a website like the following:

Testing heroku working

Congratulations! That website is running code you have on your computer that you have uploaded. You have actually made a very simple Clojure app, and your computer is all set up to make more.

Troubleshooting

Students with Windows 7 may get the error below when they run

lein repl

for the first time.

Address family not supported by protocol family: connect

If the error message is this, look at http://stackoverflow.com/a/21383865.

This error happens because lein command couldn't download necessary stuffs because a program called Relevant Knowledge, some sort of spyware, blocks the traffic. To solve this problem, uninstall Relevant Knowledge. This requires users' (owner's or administrator's) password. Sometimes, attendees haven't heard of such permission stuff. Be ready for that.

Windows 8 Setup

Starting a command prompt

For these instructions, and for much of the class, you will need to have a command prompt open. This is a text-based interface to talk to your computer. Go to the "Windows" screen (the "Start Screen") and type "command". Choose the "Command Prompt" program, like in this screenshot:

Starting a command prompt

When you choose "Command Prompt," your screen should look similar to this:

Command prompt

If you have never used the command prompt before, you may want to spend some time reading up on command prompt basics. For the rest of this setup, I will tell you to run commands in your command prompt. When I say that, I mean "type the command into the command prompt and press the Return key."

On other operating systems, the command prompt is called the terminal. We will use the terms terminal, command prompt, and command line interchangably.

Installing Java

Go to Oracle website. Then, you should see a screen like the following:

First page of Java download

Click the button above "Java Platform (JDK)," as you can see in the above picture. Then you will come to a page that will have the following table on it:

Second page of Java download

Click the radio button to accept the license agreement, and then download one of the two Windows choices. If you are running 32-bit Windows, choose "Windows x86." If you are running 64-bit Windows, choose "Windows x64."

If you do not know if you are running 32-bit or 64-bit Windows, go to the "Windows" screen (the "Start Screen") and type "system." Choose "System." (If that does not work, type "Control Panel" and choose "System" from the Control Panel screen.) You should see a window like the following:

Windows My Computer properties

You should see if you are running 32- or 64-bit Windows beside "System Type."

Once you have downloaded the right Java version, run the executable you downloaded to install Java. Follow the installation wizard.

Installing Leiningen

Leiningen is a tool used on the command line to manage Clojure projects.

Next, go to the Leiningen Windows installer site and download the file linked as "leiningen-win-installer." Run this executable and follow the "Detailed installation" section at the Leiningen Windows Installer site. At the end of the installation, leave "Run a Clojure REPL" checked before you click "Finish." If a terminal window opens that looks like the one on the Leiningen Windows installer site, then you are good to go.

Get setup with Heroku

Heroku is the tool we will use in order to put your application online where others can see it.

First, we need to create an account. Go to Heroku and click the "Sign up" link.

Heroku step 1

You will be taken to a form where you need to enter your email address in order to sign up. Fill out that form, and you will be sent an email with a link to click to continue the signup process.

Heroku step 2

After clicking on the link, you will be directed to check your email for a comfirmation messages.

Heroku step 2

An email from Heroku will contain a link to click which will confirm that the new account is connected to a valid email address.

Heroku step 2

After clicking on the link in the email, you will be taken to another form where you will need to choose a password. Choose one and enter it twice.

Heroku step 3

After all that, go here and download the installer appropriate for you system (probably 64-bit).

Heroku dashboard

If you do not see this link on your dashboard, you can download the toolbelt from toolbelt.heroku.com.

You will download an .exe file. Run this executable to install the Heroku Toolbelt and follow all prompts from the installation wizard.

Now you can login to heroku the first time:

clojurista@mylaptop$ heroku login
Enter your Heroku credentials.
Email: clojurista@gmail.com
Password (typing will be hidden): ++++++++
Logged in as clojurista@gmail.com
clojurista@mylaptop$

Testing your setup

You have set up Java, Leiningen, Atom, Git, and Heroku on your computer, all the tools you will need for this program. Before starting, we need to test them out. Make sure you have a terminal (OS X) or command prompt (Windows) open for testing. We will just call this a terminal from now on.

Go to your terminal and run the following command:

git clone https://github.com/heroku/clojure-sample.git

This will check out a sample Clojure application from GitHub, a central repository for lots of source code. Your terminal should look similar to this picture:

Testing git clone

Then run the command:

cd clojure-sample

This will put you in the directory with the source code for this sample bit of Clojure code. After that completes, run:

lein repl

This could take a long time, and will download many other pieces of code it relies on. You should see lines that start with Retrieving ... on your screen. When it finishes, your terminal should look like the following:

Testing lein repl

This is starting a REPL, which we will learn about soon. It's a special terminal for Clojure. At the REPL prompt, type (+ 1 1) and hit enter. Did you get the answer 2 back? You will learn more about that in the course.

For now, enter (quit) to quit the REPL. (NOTE: you can also type (exit) or press the Control button and D button on your keyboard together). This should take you out of the Clojure REPL and back to your normal terminal prompt.

We only have one more thing to test, Heroku.

Go back to your terminal. You should still be in the clojure-sample directory.

Run this command:

heroku create

There should be output about something being created. A URL will be displayed. Look at the following example:

Testing heroku create

Next, run the following commands:

git push heroku master

heroku open

Enter "yes" if you are asked if you are sure you want to connect.

Your browser should open (and take a long time to load) and you should see a website like the following:

Testing heroku working

Congratulations! That website is running code you have on your computer that you have uploaded. You have actually made a very simple Clojure app, and your computer is all set up to make more.

Windows 10 Setup

Starting a command prompt

For these instructions, and for much of the class, you will need to have a command prompt open. This is a text-based interface to talk to your computer. Click the "Windows" button in the bottom left and type "command" in the "Ask me anything" box. Choose the "Command Prompt" desktop app, like in this screenshot:

Starting a command prompt

When you choose "Command Prompt," your screen should look similar to this:

Command prompt

If you have never used the command prompt before, you may want to spend some time reading up on command prompt basics. For the rest of this setup, I will tell you to run commands in your command prompt. When I say that, I mean "type the command into the command prompt and press the Return key."

On other operating systems, the command prompt is called the terminal. We will use the terms terminal, command prompt, and command line interchangably.

Installing Java

Go to Oracle website. Then, you should see a screen like the following:

First page of Java download

Click the button above "Java Platform (JDK)," as you can see in the above picture. Then you will come to a page that will have the following table on it:

Second page of Java download

Click the radio button to accept the license agreement, and then download one of the two Windows choices. If you are running 32-bit Windows, choose "Windows x86." If you are running 64-bit Windows, choose "Windows x64."

If you do not know if you are running 32-bit or 64-bit Windows, click the "Windows" button and type "system." Choose "System." (If that does not work, type "Control Panel" and choose "System" from the Control Panel screen.) You should see a window like the following:

Windows My Computer properties

You should see if you are running 32- or 64-bit Windows beside "System Type."

Once you have downloaded the right Java version, run the executable you downloaded to install Java. Follow the installation wizard.

Installing Leiningen

Leiningen is a tool used on the command line to manage Clojure projects.

Next, go to the Leiningen Windows installer site and download the file linked as "leiningen-win-installer." Run this executable and follow the "Detailed installation" section at the Leiningen Windows Installer site. At the end of the installation, leave "Run a Clojure REPL" checked before you click "Finish." If a terminal window opens that looks like the one on the Leiningen Windows installer site, then you are good to go.

Get setup with Heroku

Heroku is the tool we will use in order to put your application online where others can see it.

First, we need to create an account. Go to Heroku and click the "Sign up" link.

Heroku step 1

You will be taken to a form where you need to enter your email address in order to sign up. Fill out that form, and you will be sent an email with a link to click to continue the signup process.

Heroku step 2

After clicking on the link, you will be directed to check your email for a comfirmation messages.

Heroku step 2

An email from Heroku will contain a link to click which will confirm that the new account is connected to a valid email address.

Heroku step 2

After clicking on the link in the email, you will be taken to another form where you will need to choose a password. Choose one and enter it twice.

Heroku step 3

After all that, go here and download the installer appropriate for you system (probably 64-bit).

Heroku dashboard

If you do not see this link on your dashboard, you can download the toolbelt from toolbelt.heroku.com.

You will download an .exe file. Run this executable to install the Heroku Toolbelt and follow all prompts from the installation wizard.

Now you can login to heroku the first time:

clojurista@mylaptop$ heroku login
Enter your Heroku credentials.
Email: clojurista@gmail.com
Password (typing will be hidden): ++++++++
Logged in as clojurista@gmail.com
clojurista@mylaptop$

Testing your setup

You have set up Java, Leiningen, Atom, Git, and Heroku on your computer, all the tools you will need for this program. Before starting, we need to test them out. Make sure you have a command prompt (Windows) open for testing. We will just call this a terminal from now on.

Go to your terminal and run the following command:

git clone https://github.com/heroku/clojure-sample.git

This will check out a sample Clojure application from GitHub, a central repository for lots of source code. Your terminal should look similar to this picture:

Testing git clone

Then run the command:

cd clojure-sample

This will put you in the directory with the source code for this sample bit of Clojure code. After that completes, run:

lein repl

This could take a long time, and will download many other pieces of code it relies on. You should see lines that start with Retrieving ... on your screen. When it finishes, your terminal should look like the following:

Testing lein repl

This is starting a REPL, which we will learn about soon. It's a special terminal for Clojure. At the REPL prompt, type (+ 1 1) and hit enter. Did you get the answer 2 back? You will learn more about that in the course.

For now, enter (quit) to quit the REPL. (NOTE: you can also type (exit) or press the Control button and D button on your keyboard together). This should take you out of the Clojure REPL and back to your normal terminal prompt.

We only have one more thing to test, Heroku.

Go back to your terminal. You should still be in the clojure-sample directory.

Run this command:

heroku create

There should be output about something being created. A URL will be displayed. Look at the following example:

Testing heroku create

Next, run the following commands:

git push heroku master

heroku open

Enter "yes" if you are asked if you are sure you want to connect.

Your browser should open (and take a long time to load) and you should see a website like the following:

Testing heroku working

Congratulations! That website is running code you have on your computer that you have uploaded. You have actually made a very simple Clojure app, and your computer is all set up to make more.

Linux Setup

Starting a terminal

For these instructions, and for much of the class, you will need to have a terminal, or command line, open. This is a text-based interface to talk to your computer, and you can open it by clicking "Dash Home" and typing Terminal. You can also open a terminal at any time by pressing CTRL-ALT-T. If you have never used the terminal before, you may want to spend some time reading up on command-line basics.

Go ahead and open your terminal now. It should look something like this:

blank terminal

The prompt (where you will type your commands) may look different: it usually shows the computer name and user name, as well as the folder or directory you are currently in.

For the rest of this setup, I will tell you to run commands in your terminal. When I say that, I mean "type the command into the terminal and press the Return key."

Installing Git and Ruby

The git version control system is packaged for your Linux distribution. On Debian Ubuntu systems you can install it with the following (as the superuser):

root@mylaptop# apt-get update
root@mylaptop# apt-get install git git-core git-man ruby

NOTE: We are installing Ruby because it's needed by the Heroku Command Line Interface

Installing Java

On Ubuntu you should be able to install Java with:

sudo apt install default-jdk

Installing Leiningen

Leiningen is a tool used on the command line to manage Clojure projects.

Go to the Leiningen website. You will see a link to the lein script under the "Install" heading. Right-click that link and choose "Save Link As...". Save it in your Downloads directory.

Leiningen site Leiningen site

After that, run the following commands in your terminal:

clojurista@mylaptop$ mkdir ~/bin
clojurista@mylaptop$ cd ~/bin
clojurista@mylaptop$ mv ~/Downloads/lein ./
clojurista@mylaptop$ chmod +x lein
clojurista@mylaptop$ lein version
Leiningen 2.7.1 on Java 1.8.0_112 Java HotSpot(TM) 64-Bit Server VM
clojurista@mylaptop$

After you run the above commands, run the lein version command. It should take a while to run, as it will download some resources it needs the first time. If it completes successfully, you are golden! If not, ask an instructor for help.

Installing the Heroku Command Line Interface (CLI)

Heroku is the tool we will use in order to put your application online where others can see it.

First, we need to create an account. Go to Heroku and click the "Sign up" link.

Heroku step 1

You will be taken to a form where you need to enter your email address in order to sign up. Fill out that form, and you will be sent an email with a link to click to continue the signup process.

Heroku step 2

After clicking on the link, you will be taken to another form where you will need to choose a password. Choose one and enter it twice.

Heroku step 3

After all that, you should be at your Heroku dashboard. There will be a link on the dashboard to download the Heroku Command Line Interface. Download it now.

Heroku dashboard

If you do not see this link on your dashboard, you can download the Heroku Command Line Interface from toolbelt.heroku.com.

From the "Heroku Command Line" web page you can copy/paste the command to script to install the Heroku Command Line Interface to /usr/local/heroku (as the superuser):

root@mylaptop# wget -qO- https://toolbelt.heroku.com/install.sh | sh
This script requires superuser access to install software.
You will be prompted for your password by sudo.
Add the Heroku CLI to your PATH using:
$ echo 'PATH="/usr/local/heroku/bin:$PATH"' >> ~/.profile
root@mylaptop#

NOTE: We already added /usr/local/heroku/bin to the PATH above

You can test that the basic heroku command works like this:

clojurista@mylaptop$ heroku --version
heroku-toolbelt/3.43.12 (x86_64-linux-gnu) ruby/2.3.1
heroku-cli/5.4.8-eee5ec9 (linux-amd64) go1.7.1
You have no installed plugins.
clojurista@mylaptop$

Now you can login to heroku the first time:

clojurista@mylaptop$ heroku login
Enter your Heroku credentials.
Email: clojurista@gmail.com
Password (typing will be hidden): ++++++++
Logged in as clojurista@gmail.com
clojurista@mylaptop$

Testing your setup

You have set up Java, Atom, Leiningen, Git, and Heroku on your computer -- all the tools you will need for this course. Before starting, we need to test them out.

Go to your terminal and download a copy of the clojure-getting-started repository:

clojurista@mylaptop$ mkdir -p ~/src/github/heroku
clojurista@mylaptop$ git clone https://github.com/heroku/clojure-getting-started.git
clojurista@mylaptop$ cd clojure-getting-started
clojurista@mylaptop$

Now you can start the sample application on your laptop using lein repl. This could take a long time, and will download many other pieces of code it relies on. You should see lines that start with Retrieving ... on your screen.

Below you see the first two Clojure commands start the application. You can then visit the application webpage on your laptop at http://localhost:5000. Then you can shut down the application and (quit) with the last two commmands.

  1. lein repl
  2. (require 'clojure-getting-started.web)
  3. (def server (clojure-getting-started.web/-main))
  4. Now you can open the web page at http://localhost:5000 heroku test page
  5. (.stop server)
  6. (quit)
clojurista@mylaptop$ lein repl
Retrieving environ/environ.lein/0.3.1/environ.lein-0.3.1.pom from clojars
Retrieving environ/environ.lein/0.3.1/environ.lein-0.3.1.jar from clojars
Warning: cider-nrepl requires Clojure 1.7 or greater.
Warning: cider-nrepl will not be included in your project.
Warning: cider-nrepl requires Clojure 1.7 or greater.
Warning: cider-nrepl will not be included in your project.
Retrieving environ/environ/1.0.0/environ-1.0.0.pom from clojars
Retrieving environ/environ/1.0.0/environ-1.0.0.jar from clojars
nREPL server started on port 42509 on host 127.0.0.1 - nrepl://127.0.0.1:42509
REPL-y 0.3.7, nREPL 0.2.12
Clojure 1.6.0
OpenJDK 64-Bit Server VM 1.8.0_111-8u111-b14-2-b14
    Docs: (doc function-name-here)
          (find-doc "part-of-name-here")
  Source: (source function-name-here)
 Javadoc: (javadoc java-object-or-class-here)
    Exit: Control+D or (exit) or (quit)
 Results: Stored in vars *1, *2, *3, an exception in *e

user=> (require 'clojure-getting-started.web)
2016-10-28 14:05:21.439:INFO::nREPL-worker-0: Logging initialized @17071ms
nil
user=> (def server (clojure-getting-started.web/-main))
(def server (clojure-getting-started.web/-main))
2016-10-28 14:05:30.163:INFO:oejs.Server:nREPL-worker-0: jetty-9.2.10.v20150310
2016-10-28 14:05:30.203:INFO:oejs.ServerConnector:nREPL-worker-0: Started ServerConnector@379cb9a6{HTTP/1.1}{0.0.0.0:5000}
2016-10-28 14:05:30.204:INFO:oejs.Server:nREPL-worker-0: Started @25837ms
#'user/server
user=> (println "open http://localhost:5000")
open http://localhost:5000
user=> (.stop server)
2016-10-28 14:06:15.811:INFO:oejs.ServerConnector:nREPL-worker-1: Stopped ServerConnector@379cb9a6{HTTP/1.1}{0.0.0.0:5000}
nil
user=> (quit)
Bye for now!
clojurista@mylaptop$

Yay! Your first web application works on your laptop!

Now you can push the application to the web via heroku create:

clojurista@mylaptop$ heroku create
Creating app... done, enigmatic-beyond-54459
https://enigmatic-beyond-54459.herokuapp.com/ | https://git.heroku.com/enigmatic-beyond-54459.git
clojurista@mylaptop$ git push heroku master
Counting objects: 41, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (38/38), done.
Writing objects: 100% (41/41), 6.36 KiB | 0 bytes/s, done.
Total 41 (delta 15), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Clojure (Leiningen 2) app detected
remote: -----> Installing OpenJDK 1.8... done
remote: -----> Installing Leiningen
remote:        Downloading: leiningen-2.6.1-standalone.jar
remote:        Writing: lein script
remote: -----> Building with Leiningen
remote:        Running: lein uberjar
remote:        Retrieving environ/environ.lein/0.3.1/environ.lein-0.3.1.pom from clojars
...more output...
remote: -----> Launching...
remote:        Released v3
remote:        https://enigmatic-beyond-54459.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/enigmatic-beyond-54459.git
 * [new branch]      master -> master
clojurista@mylaptop$ heroku open
clojurista@mylaptop$

Your browser should open (and take a long time to load), and you should see a website like the following:

Nightcode

If your browser does not open after running heroku open, start a browser and go to the URL displayed after you ran heroku create.

Congratulations! That website is running the code you have uploaded to the Interet!!! You have made a very simple Clojure app and you are all set up to make more!

You're ready for the workshop!!!