arrow-left

All pages
gitbookPowered by GitBook
1 of 3

Loading...

Loading...

Loading...

0.2. Quiz

Quiz 0: Getting Started

hashtag
Coding

Right-click on the src/main/javaarrow-up-right directory under the project and create the package edu.emory.cs.utilsarrow-up-right. Right-click on the utils package and create the Java class Utilsarrow-up-right:

  • Add Utils.java to git.

  • Add the following methods to the Utils class:

Run the program by clicking [Run -> Run]. If you see 5 on the output pane, your program runs successfully.

hashtag
Testing

Open and add the following configurations (if not already), which would allow you to perform :

Right-click on the directory under the project and create the package . Right-click on the utils package and create the Java class :

  • Add UtilsTest.java to Git.

  • Add the following method to the UtilsTest class. Make sure to include all imports:

Run the test by clicking [Run -> Run]. If you see the test passed, your unit test runs successfully.

hashtag
Submission

  1. Add the instructors as collaborators in your GitHub repository:

  • Jinho Choi: jdchoi77

  • Peilin Wu: qualidea1217

  • Jeongrok Yu: jeongrok

2. Commit and push the following to your GitHub repository:

3. Submit the URL of your GitHub repository to Canvas.

Zinc Zhao: ZincZhao

  • build.gradlearrow-up-right
    JUnit Testingarrow-up-right
    src/test/javaarrow-up-right
    edu.emory.cs.utilsarrow-up-right
    UtilsTestarrow-up-right
    gradle/wrapper/gradle-wrapper.jararrow-up-right
    gradle/wrapper/gradle-wrapper.propertiesarrow-up-right
    .gitignorearrow-up-right
    static public int getMiddleIndex(int beginIndex, int endIndex) {
        return beginIndex + (endIndex - beginIndex) / 2;
    }
    
    static public void main(String[] args) {
        System.out.println(getMiddleIndex(0, 10));
    }
    test {
        useJUnitPlatform()
    }
    
    dependencies {
        testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
        testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
    }
    package edu.emory.cs.utils;
    
    import org.junit.jupiter.api.Test;
    import static org.junit.jupiter.api.Assertions.assertEquals;
    
    @Test
    public void getMiddleIndexTest() {
        assertEquals(5, Utils.getMiddleIndex(0, 10));
    }
    build.gradlearrow-up-right
    gradlewarrow-up-right
    gradlew.batarrow-up-right
    settings.gradlearrow-up-right
    src/main/java/edu/emory/cs/utils/Utils.javaarrow-up-right
    src/test/java/edu/emory/cs/utils/UtilsTest.javaarrow-up-right

    0. Getting Started

    This chapter helps you set up the development environment for this course.

    hashtag
    Contents

    1. Environment Setup

    hashtag
    Resources

    • Main:

    • Test:

    circle-info

    Many Java developers commonly adapt to the environment described in this section. Thus, it is essential to familiarize yourself with this setup.

    Quiz
    src/main/java/edu/emory/cs/utils/Utils.javaarrow-up-right
    src/test/java/edu/emory/cs/utils/UtilsTest.javaarrow-up-right

    0.1. Environment Setup

    Development kit, version control system, integrated development environment, and project management for Java programming.

    hashtag
    Development Kit

    Install the latest version of the Java SE Development Kitarrow-up-right (JDK) on your local machine:

    • The required version: 17.x.x (or higher)

    circle-info

    Although Java 17 is not the most recent version, it is the latest long-term support (LTS) release, which is preferred.

    hashtag
    Version Control

    Install Git using any of the following instructions:

    Run the following commands on a terminal by replacing user.email and user.name with your email address and name:

    hashtag
    Integrated Development Environment

    Install the latest version of on your local machine:

    • The recommended version: 2022.3.x (Ultimate Edition)

    • Apply for the with your school email address to use the ultimate version.

    circle-info

    Even if you already have an IDE that you are familiar with for Java programming, we strongly recommend you use IntelliJ because provides IDEs for many popular programming languages with similar interfaces, which makes it easier for you to adapt.

    hashtag
    Project Management

    Launch IntelliJ and create a project by clicking the [New Project] button at the top:

    • Name: dsa-java

    • Location: local_path/dsa-java

    • Check "Create Git repository"

    circle-info

    For JDK, you should be able to see version 17 if it is properly installed. If you cannot find the version, click [Add JDK] and select the following directory.

    • Windows: C:\Program Files\Java\jdk-17.x.x

    Open and make sure distributionUrl indicates the latest version of Gradle:

    Click [Settings - Build, Execution, Deployment] on the menu:

    • Click [Build Tools - Gradle] and set Gradle JVM to 17.

    • Click [Compiler - Java Compiler] and set Project bytecode version to 17.

    Click [File - Project Structure] and select [Project Settings]:

    • Click [Project Settings - Project] and set SDK to 17 and Project language level to SDK default.

    • Click [Project Settings - Modules - Dependencies] and set Module SDK to 17.

    Open and make sure sourceCompatibility and targetCompatibility are set to java version 17 (add the following configurations if they do not exist already):

    Lastly, check mavenCentral() is configured as a repository in your build.gradle:

    circle-info

    There is another popular build tool called . However, we will use Gradle for this course because it is faster and simpler to build a Java-based project.

    hashtag
    GitHub Integration

    To integrate the project with your repository, click [Settings]:

    • Choose [Version Control - Github] on the left pane.

    • Click [+] and login with your GitHub ID and password.

    • If you use two-factor authentication, log in with your .

    Create under the project and add the following contents:

    Click [Git - GitHub - Share Project on Github] and create a repository:

    • Make sure to check private.

    • Repository name: dsa-java

    • Remote: origin

    Add all files and make the initial commit. Check if the repository is created under your GitHub account: https://github.com/your_id/dsa-java.

    circle-info

    We recommend you create a GitHub account with your school email address, allowing you to add unlimited collaborators to the repository.

    Language: Java

  • Build system: Gradle

  • JDK: 17

  • Gradle DSL: Groovy

  • Uncheck "Add sample code"

  • Advanced Settings:

    • GroupId: edu.emory.cs

    • ArtifactId: dsa-java

  • Mac: /Library/Java/JavaVirtualMachines/jdk-17.x.x.jdk

    Go to [Platform Settings - SDKs] and select 17.

    Description: Data Structures and Algorithms in Java

    Git Installation Guide by Bitbucketarrow-up-right
    Git Installation Guide by GitHubarrow-up-right
    IntelliJ IDEAarrow-up-right
    academic licensearrow-up-right
    JetBrainsarrow-up-right
    Gradlearrow-up-right
    gradle/wrapper/gradle-wrapper.propertiesarrow-up-right
    build.gradlearrow-up-right
    Mavenarrow-up-right
    GitHubarrow-up-right
    personal access tokenarrow-up-right
    .gitignorearrow-up-right
    Most-Used Java IDEs of 2021 -
    Large Multi-project Build Times -
    git config --global user.email "your_id@emory.edu"
    git config --global user.name "Your Name"
    distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip
    compileJava {
        sourceCompatibility = JavaVersion.VERSION_17
        targetCompatibility = JavaVersion.VERSION_17
    }
    repositories {
        mavenCentral()
    }
    /.gradle/
    /.idea/
    /.vscode/
    /build/
    2021 Java Developer Productivity Reportarrow-up-right
    Gradle vs Maven: Performance Comparisonarrow-up-right