-
Notifications
You must be signed in to change notification settings - Fork 5
Getting Started
Jinho D. Choi edited this page Jan 21, 2015
·
8 revisions
- 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.
- 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
CS325
by choosingFile -> New -> Java Project
. - Create a package
utils
by right-clicking[CS325] -> New -> Package
. - Create a class
MathUtils
by right-clicking{utils} -> New -> Class
. - Add the following methods to the
MathUtils
class:
static public double divide(int numerator, int denominator)
{
return (double)numerator / denominator;
}
static public void main(String[] args)
{
System.out.println(divide(1, 2));
}
- Run the program by choosing
Run -> Run
. - If you see
0.5
on the console, your program is successfully run.
- Right click on the
CS325
project and chooseBuild Path -> Add Libraries
. - Choose
JUnit
and addJUnit 4
. - Create a class
MathUtilsTest
under theutils
package. - Add the following method to the
MathUtilsTest
class. - Make sure to include the
@Test
annotation.
@Test
public void divideTest()
{
assertEquals(MathUtils.divide(1, 2), 0.5, 0);
}
- Run the test by choosing
Run -> Run
. - If you see a green bar, your test is passed.
- Login to
lab0z.mathcs.emory.edu
. - Create a directory
quiz0
under thecs325
directory. - Put
MathUtils.java
andMathUtilsTest.java
undercs325/quiz0
. - If you are using a Windows machine with no command-line tools:
- Use an FTP client (e.g., FileZilla) to upload your files.
- If you are using a Mac/Linux machine:
- Run the following command (replace
yourID
with yourmathcs
ID).
rsync -avc MathUtils.java MathUtilsTest.java yourID@lab0z.mathcs.emory.edu:~yourID/cs325/quiz0/
©2015 Emory University