You need to install the development tools your personal computer, both to build the sample code, and work on your assignments (for various reasons, you cannot use lab computers for this course). This section explains what software to install.
1/ Command-Line Tools Setup
This video walks through installing Git, Gradle, and Java and building sample code from the command-line.
Getting started with Java.
You will need to install the following:
* Git Client 2.24 or later. Required to fetch code samples and submit assignments.
* OpenJDK 15.0.2. Libraries, compiler and related tools.
* Gradle 7.0. Build system that works with Java.
Make sure that the programs are in your path so that they can be executed directly.
2/ IntelliJ Setup
IntelliJ is a powerful Open Source Java IDE. It's optional for the first few assignments, but required for Android development. It supports a number of very helpful features (e.g. code completion, API documentation tooltips, debugging, profiling) and is highly recommended.
This video describes setting it up:
Getting started with IntelliJ.
3/ Sample CodeWe have a public repository containing the sample code shown in lectures: https://git.uwaterloo.ca/cs349-public/1215.
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 maintained in a public Git repository. To get a copy,
git clone the repository URL:
$ git clone https://git.uwaterloo.ca/cs349-public/1215.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 projects 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.UndoRedo ├── 10.Responsiveness └── README.md
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.gradlefile. 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.
Creating a New Project in IntelliJ
The following steps will setup a Gradle project that works from both the command-line and from within IntelliJ.
- In IntelliJ, File -> New Project. Select Gradle/Java as the type of project.
- Provide a name and location, and click OK. This will create a project.
- From the Project panel on the left (Cmd-1 to toggle it), you will see a list of files. Open build.gradle.
- Change the contents of the build.gradle file to this:
- Create a source file in the
src/main/javafolder (in this example,
- From the Gradle menu (View -> Tools -> Gradle), you should be able to "Build" and "Run" your application.
- Make sure that any new files that you add or create are placed in the appropriate subdirectory (
src/main/javafor source code, and
src/main/resourcesfor images or other assets).