Programming fundamentals
Programming Fundamentals
Lewis University
TUTORIAL: How to Get Started Programming with Java in Eclipse IDE
1. Download and install the Java Development Kit (JDK). https://www.oracle.com/technetwork/java/javase/downloads/index.html
2. Download and execute Eclipse IDE for Java Developers. https://www.eclipse.org/downloads/packages/
3. Close the Welcome screen.
4. Right-click on the empty area in the Package Explorer window and
hover with your mouse over New…Java Project. Then click it to make a
new project.
5. After the New...Java Project window opens, enter the name of your
project (e.g. “MyFirstProject”). Also, make sure that “Use an execution
environment JRE” is set to “JavaSE-1.8”. This is the version of Java we
will use in class. Then click on “Finish”.
6. After the project gets created, you should see its name in the Package
Explorer window. Click on the triangle next to the name to expand the
contents. It displays any folders and files that are associated with this
project. Right-click on “src” then hover over New..Class. Then click it to
add a new class to your project.
7. In the New Java Class window, enter the name of your class (e.g.
MyProgram) and make sure “public static void main(String[] args)” is
selected. Note that class names should be in title case. Click finish to add
the class to your project.
8. You should now see the following:
You are now ready to add code your class. When you execute a
program, it will run the class with the main method. You can remove
this comment: “// TODO Auto-generated method stub”. Replace it with
your program code.
9. For example, this code computes the area of a circle for a radius of 10: double radius = 10.0; double areaOfCircle = Math.PI * Math.pow(radius, 2); System.out.println("Area of the circle is " + areaOfCircle);
After entering this code in the main method body, you can execute it by
going to Run..Run or hitting CTRL+F11 (use command on the Mac).
The output will show in the Console window on the bottom, as shown
below:
- TUTORIAL: How to Get Started Programming with Java in Eclipse IDE