Skip to content
jdchoi77 edited this page Jan 4, 2015 · 8 revisions

Java Development Kit (JDK)

  • Download the latest version of JDK from here and install.
  • Make sure the version is 1.8.x or higher by typing java -version on a terminal.

Eclipse

  • Download the latest version of Eclipse from here and install.
  • Launch Eclipse by double-clicking the icon.
  • If it prompts to specify a working directory, keep the default one (Workspace).
  • If it shows a Welcome tab, close the tab.
  • Create a new project CS323 by choosing File -> New -> Java Project.
  • Create a package cs323.utils by right-clicking [CS323] -> New -> Package.
  • Create a class MathUtils by right-clicking {cs323.utils} -> New -> Class.
  • Add the following methods to the MathUtils class:
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));
}
  • Run the program by choosing Run -> Run.
  • If you see 5 on the console, your program is successfully run.

JUnit Test

  • Right click on the CS323 project and choose Build Path -> Add Libraries.
  • Choose JUnit and add JUnit 4.
  • Create a class MathUtilsTest under the utils package.
  • Add the following method to the MathUtilsTest class.
  • Make sure to include the @Test annotation.
@Test
public void testSum()
{
    assertEquals(MathUtils.getMiddleIndex(0, 10), 5);
}
  • Run the test by choosing Run -> Run.
  • If you see a green bar, all your tests have passed.

Artificial Intelligence

Instructor


Emory University

Clone this wiki locally