How to Write Your First Java Program

by pemorr in Circuits > Software

411 Views, 1 Favorites, 0 Comments

How to Write Your First Java Program

Annotation 2020-02-25 124118.png

This tutorial shows you how to write your first Java program step by step.

Supplies

Computer

Internet Connection

Download the Java JDK

14.png
13.png

Go to https://www.oracle.com/java/technologies/javase-jdk13-downloads.html and click the link that matches the machine you are using. Then, accept the license agreement.

Download Eclipse

15.png
16.png
12.png

Go to https://www.eclipse.org/downloads/ and click on the circled buttons to start the download. When the download is complete, click "run". The eclipse installer will start.

Eclipse is used to write programs in an integrated environment that is easy to use.

Launch Eclipse

10.png
11.png
9.png

Launch eclipse and select "Eclipse IDE for Java Developers". Then select where you want your projects to be stored on your computer. The default option is suitable for this tutorial.

Setting Up Your Project

8.png
7.png
5.png
Annotation 2020-02-21 155131.png

Go to file->new->Java Project and name your project.

You do not need to designate a package name.

Click finish.

If Eclipse prompts your for "Module-info" click "dont create".

Next, right click on the "src" folder and click "new"->"class".

Name the file "HelloWorld" and check the boxes "public static void main (String[] args)" and "Generate Comments"

Click finish.

Writing and Running the Program

4.png
1.png

type "System.out.println("Hello World!");" between the curly braces of "public static void main(String[] args)".

Then click the green "run" button on the top left of the screen.

You should see the output of your program on the bottom of the screen.

Congratulations! You wrote your first program!

Next stop, Google!