Setup: Verify your setup

Check every tool, then write a Java program, commit it with Git, and push it to GitHub.

Novice · Operating System · Git · Java · Updated

After this lesson you can

  • Run a single-file Java program from the terminal
  • Commit a file and push it to a new GitHub repository

macOS only. This last exercise checks that your tools work together. You will write a small Java program, save it with Git, and publish it on GitHub.

Check every tool

Open a new Terminal window and run these commands one at a time:

git --version
java -version
javac -version
echo $JAVA_HOME
code --version
node --version
npm --version
mysql --version

Each one should print a version number or, for JAVA_HOME, a path. If any of them prints command not found, go back to that tool's Setup exercise.

Write a Java program

Create a folder for your bootcamp work and a project folder inside it:

mkdir -p ~/bootcamp/hello-bootcamp
cd ~/bootcamp/hello-bootcamp

Open a new Java file in VS Code:

code HelloBootcamp.java

Type this program into the file, then save it with Command+S:

public class HelloBootcamp {
    public static void main(String[] args) {
        System.out.println("Hello, bootcamp! My computer is ready.");
    }
}

Back in the Terminal, run it:

java HelloBootcamp.java

You should see Hello, bootcamp! My computer is ready.

See your project in Finder too:

open .

Finder opens your hello-bootcamp folder, with your HelloBootcamp.java file inside. The . means "the folder I am in now".

Save it with Git

git init
git add HelloBootcamp.java
git commit -m "My first Java program"

git init makes this folder a Git repository. git add chooses the file to save, and git commit saves it with a message. You should see 1 file changed.

Publish it on GitHub

  1. Sign in at github.com. Click the + at the top right and choose New repository.
  2. Set Repository name to hello-bootcamp. Leave everything else as it is: do not add a README, a .gitignore, or a license.
  3. Click Create repository.

GitHub shows a page of commands. Under …or push an existing repository from the command line, copy the line that starts with git remote add origin and run it. It looks like this, with your username:

git remote add origin https://github.com/your-username/hello-bootcamp.git

Then push your commit:

git push -u origin main

The first time you push, Git Credential Manager opens a sign-in window. Choose Sign in with your browser, then click Authorize on the GitHub page. After that, Git remembers you.

Refresh the repository page on GitHub. You should see HelloBootcamp.java. Click it to read your code online.

Check MySQL

Open MySQL Workbench, open your local connection, and run SELECT VERSION();. You should see a version that starts with 8.4.

Check Insomnia

Open Insomnia, then your Bootcamp project and its First requests collection. Click Glossary categories and click Send. You should see 200 OK and the list of categories.

You did it! Your Mac is ready for the bootcamp.

Common problems

What you see What to do
error: src refspec main does not match any The commit did not happen. Run the git add and git commit commands again, then push.
remote origin already exists You ran git remote add twice. Run git remote set-url origin followed by the address from GitHub.
Author identity unknown Set your name and email again, as in the Git Setup exercise.
error: can't find main(String[]) or main() method in class: HelloBootcamp Check the spelling of public static void main(String[] args) in your file, and save it.