Lab 01
Welcome to the first lab! At this stage, you are expected to have already installed all software needed for this course.
- Consider this lab as the final last checkpoint before things get serious. The interest of this lab is to ensure you're all operational and have a fully functional development setup.
- Going through the following exercises also serves as recap, to ensure you are able to safely navigate the technological preliminaries for java development.
Follow the instructions, don't take shortcuts.
For the first two blocks (Bash and Java), you are expected to work only using the command line. Do not use any graphical tool for these tasks. These tasks are not about programming, but about double-checking your environment and training your tool proficiency. There will be exam questions about command line use.
Command line basics
In this first block we'll check your bash installation and recap a few essential commands.
Testing your kernel
- Open a new terminal and type
uname -a. Then press enter. - The command gives details on your operation system kernel. Since you're expected to work with a Unix (Linux / Mac /
WSL), you should see a line like:
Darwin air.ddns.uqam.ca 24.4.0 Darwin Kernel Version 24.4.0: Fri Apr 11 18:34:14 PDT 2025; root:xnu-11417.101.15~117/RELEASE_ARM64_T8122 arm64
Unix is not optional
If the command is not found, or says "windows", install WSL or Ubuntu now. It is not possible to pursue this course without a unix like system.
File system access
Next we'll recap a few essential bash commands:
| Command | purpose |
|---|---|
cd |
Go to homedirectory |
cd x |
Go into a subdirectory x (if it exists) |
mkdir x |
Make a new subdirectory x |
touch y |
Create a new text file y |
Now it's your turn. Use the above commands to: (Do not use a graphical file manager)
- Enter your homedirectory
- Create a new folder
Lab01, and within two more nested folders:src, and withinsrcanother folderhelloworld - Go into the three new folders, and create a new text file
HelloWorld.java
At the end you should have created the following structure:
Inputs and outputs
So far your file structure does not do much, lets change that !
Here are a few commands to print to console and write into a file:
| Command | purpose |
|---|---|
echo 'toto' |
Write toto to terminal |
echo 'toto' > file |
Replace content of file with string toto |
cat file |
Print the content of file |
Now use these commands to do the following: (Do not use a graphical file manager)
- Test writing to console, write this string to
console:
package helloworld;class HelloWorld{public static void main(String[] args){System.out.println("Hello INF2050");}}- Note: This is indeed a java program, compressed to a single line. Do not worry about the code for now, we just want to test the console.
- If the string displays correctly, write it into the
HelloWorld.javafile. - Verify the string was correctly stored in the
HelloWorld.javafile, usingcat.
Java basics
With the previous bash commands, you've now actually created a first java program. Let's see how we can run it.
Commands
Running java actually needs two components, a compiler and an interpreter:
- The compiler translates your source code (what you just created) into java bytecode: The
javaccommand calls the java compiler. - The interpreter consumes java bytecode and feeds it as binary into your CPU: The
javacommand calls the java virtual machine, an interpreter for java bytecode.
Here's an incomplete illustration of how to compile and run bytecode from command line:

What are the missing parts ? Write your answers on a sheet of paper and afterwards verify your understanding.
What are the answers, from left to right?
HelloWorld.java
javac HelloWorld.java
HelloWorld.class
java HelloWorld
Verify your installation
So for working with java, we need two commands: javac et java. Let's check if you have the correct tools installed:
- Type
java -version. It should print something like:
openjdk version "23.0.2" 2025-07-15
OpenJDK Runtime Environment (build 23.0.2+12-54)
OpenJDK 64-Bit Server VM (build 23.0.2+12-54, mixed mode, sharing)
- Type
javac -version. It should print something like:
Double-check the version
For this course, it has to be version 23 for both compiler and interpreter (jvm). Other versions will lead to problems and likely a lower grade.
Running code
So you have source code and you have to tools to compile and run the code. Let's see if everything works as it should.
- Compile your previously created
HelloWorld.javaprogram.- Note: The source code contains a package name, so you have to call
javacfrom thesrcdirectory, not from thehelloworldpackage directory. - Verify there now is a
HelloWorld.classfile.
- Note: The source code contains a package name, so you have to call
- Start your compiled program:
- Feed the java bytecode to your JVM interpreter. Remember there still is a package name, so you have to call the
JVM from within the
srcdirectory, not from thehelloworldpackage directory. - Verify the program output is correct. It should print
Hello MGL7010to console
- Feed the java bytecode to your JVM interpreter. Remember there still is a package name, so you have to call the
JVM from within the
IntelliJ
At this point you're all set with the command line tools.
- Of course, we won't develop larger projects from command line, and instead use an integrated developer environment ( IDE).
- For this course, you'll be working with IntelliJ Ultimate.
Verify IntelliJ version
Lets start by checking you have the right version installed:
- Start up intelliJ, open the "About" option from the program menu: "IntelliJ -> About IntelliJ IDE"
- You should see a popup like this:

- Verify it says "Ultimate Edition".
You need the ultimate version
The ultimate version is not optional. In this course, we will be working with features exclusive to the ultimate version. It is not possible to adequately solve the labs or TPs with the standard version. If you do not see "Ultimate Edition", make sure to register for a free educational license now.
Importing a project
Next you'll be using your previously coded Hello World application in IntelliJ and run your code from within the IDE.
- Use the
File -> Open....- Double check you are not using any
Importoption, butOpen....
- Double check you are not using any
- A file explorer will pop up. Select the
Lab01folder you previously created. Then click theOpenbutton.- Make sure to select the
Lab01folder, and not any subfolder.
- Make sure to select the

- Once the IDE opens up, unfold the
srcfolder and access theHelloWorld.javafile. - Test code formatting:
- Mac OS: Command (⌘) + Option (⌥) + L
- Linux / Windows: Ctrl + Alt + L
- Hit the green triangle left of the code line.
- Verify it prints
Hello MGL7010.
- Verify it prints

What actually happens when you click that green triangle ?
The IDE will call the java compiler, and afterwards invoke the java virtual machine. It implicitly uses the exact same tools you were previously using from command line
Code with me
- Throughout the semester you will be often working in teams.
- While there is a standard solution for group projects (
git), for student-group project the best solution remains pair-programming. - However, often times you are not physically in the same place.
- While there is a standard solution for group projects (
- With IntelliJ "Code with me" you can turn your IDE into a shared virtual document (a bit like a google doc), and work
in pair-programming mode, even if you are not physically in the same place.
- Take a look at the "Code with me" plugin: Documentation in english
- Test the "Code with me" plugin with the student next to you:
- Verify you see the same code.
- Verify you can both edit the code.
Object comparison
In class, we've discussed that there is a fundamental difference between comparing primitives, and comparing objects.
Below is a short program, which features an unsafe object comparison.
- Copy and paste the program into your IDE.
- Before running the program, form a hypothesis of it's output.
- Write your answer on a sheet of paper.
- For each output, briefly add a supporting argument.
- Run the program verify your hypothesis.
Take a close look at listOfString's type.
In class you've learned how to distinguish primitive types from object types, take a close look at the first character.
import java.util.LinkedList;
public class Main {
public static void main(String[] args) {
LinkedList<String> listWithNames = new LinkedList<>();
listWithNames.add("Fatoumata");
listWithNames.add("Leila");
listWithNames.add("Paul");
listWithNames.add("ElMehdi");
LinkedList<String> listWithSameNames = new LinkedList<>();
listWithSameNames.add("Fatoumata");
listWithSameNames.add("Leila");
listWithSameNames.add("Paul");
listWithSameNames.add("ElMehdi");
// What does this print ? true or false ?
System.out.println(listWithNames == listWithSameNames);
// What does this print ? true or false ?
System.out.println(listWithNames.equals(listWithSameNames));
}
}