Samples
This page describes how to compile and run code samples shown in the lectures. Make sure you have setup your environment first.
You are allowed to use these samples in your assignments. If you do so, please make a comment in the code indicating which one you used.
Fetch a local copy of the samples
Samples are all in a public Git repository. To get a copy, git clone
the repository URL:
$ git clone https://git.uwaterloo.ca/cs349-public/1211.git cs349
You should see the following directory structure. Each of the numbered folders represents a section in the course, and contains multiple projects. All of them are built using Gradle and IntelliJ and should be runnable from within the IDE.
. ├── 01.Intro ├── 02.JavaFX ├── 03.Graphics ├── 04.Events ├── 05.Widgets ├── 06.Layout ├── 07.MVC ├── 08.Android ├── 09.Extra ├── README.md ├── starter ├── starter-commandline └── starter-graphical
Building from the Command-Line
Gradle projects can be built and executed directly from the command-line:
$ cd cs349 $ cd 01.Intro/01.hello_world $ gradle build Starting a Gradle Daemon (subsequent builds will be faster) BUILD SUCCESSFUL in 4s 5 actionable tasks: 5 up-to-date $ gradle run > Task :run Hello world! BUILD SUCCESSFUL in 767ms 3 actionable tasks: 2 executed, 1 up-to-date
Building from IntelliJ
Projects can also be built in IntelliJ:
- In IntelliJ, File -> Open and navigate to the top-level directory containing the
build.gradle
file. Do NOT open a specific file, just the directory. - After it has loaded, use View -> Tools -> Gradle to show the Gradle tasks window, and use build -> build and application -> run to Build and Run respectively.

Templates
The public repository contains two starter projects that you can use. Both of these are empty projects that are buildable from the command-line or within IntelliJ. You can copy and modify these if you wish.
- starter: "flat" structure suitable for console applications
- starter-commandline: console application that prints "Hello World" on the command-line
- starter-graphical: GUI application that displays "Hello World" in a graphical window