In this post I will help you setting up the development environment – Eclipse – you need to start programming in Java, leading you through each step.



In order to start programming in Java, you need an IDE that can manage, compile and run the programs you’re going to write.

The reason why I’ve chosen Eclipse for this guide is that I’ve used it for a long time and it’s never given me serious problems.

Without further ado, let’s download and install it and write our first program.

Downloading Eclipse


First of all go to the official Eclipse’s download page: https://www.eclipse.org/downloads/

Download Eclipse step #1

1. Click Download under Get Eclipse IDE.

Downloading Eclipse step #2

Click Download in the newly opened page, too.

2. Wait for the download to finish and you’re ready for the next part.

Installing Eclipse


Open the installer (.exe file) you’ve just downloaded.

Installing Eclipse step #1

A message like the one you see in the picture above will appear.

3. Click Run.

Installing Eclipse step #2

4. Select the first option: Eclipse IDE for Java Developers.

Installing Eclipse step #3

5. Choose where you want to install Eclipse – I already had a folder with an older version of Eclipse in it – and click Install.

Wait for the installation to finish and then open Eclipse: you still have one step left for this part.

Installing Eclipse step #4

6. Choose a directory for you projects: all the programs and files you’ll create will be saved there.

Making your first program


Now we’re going to make our first program in Java, just to see how Eclipse works.

Next week we’ll learn the basics of Java, such as what are classes, packages and object-oriented programming, therefore follow me on Twitter to avoid missing new posts.

In the top left corner, click on File->New->Java Project.

Creating a new project step #1

This window allows you to create a new project – that is a group of files that belong to the same program.

Choose a name that you like.

Creating a new project step #2

As you can see, the project has been created and inside it you can fine a folder called src.

Creating a new project step #3

Right-click on src->New->Package to create a package – they’re usually used to hold all files of the project that perform a similar task.

Right-click on the package and create a Class: this is the file that will contain our code.

Here’s our code: it prints “Enter something:“, it goes to a new line and it waits for an answer, which then is printed again.

As I said, for further details on how Java works, you should read the next article.

For now, I’ll just tell you that:

  • System.out.println(“Enter something:”); is the equivalent of C’s printf(“Enter something:\n”);

    You should learn the basic concepts of programming through this guide about C, if you haven’t, otherwise further posts will be hard to understand.

  • String answer; is a list of characters: unlike arrays, a list has got indefinite length.
  • Scanner in = new Scanner(System.in); creates an object ( more on that next week ) that allows the program to read from the input stream ( System.in ).
  • answer = in.nextLine(); reads a line and it assigns it to answer.
  • System.out.println(answer); prints the answer back.

Conclusion


Today you’ve installed Eclipse, so that you’re ready to start programming in Java.

While the previous guide – the one about C – was an introduction to the most important concepts of programming, this one focuses on object-oriented programming.

This means that it’ll be more pragmatic, full of examples and interesting projects.

However you need to learn some new concepts: I’m going to teach you those in the next post.

Remember that you can always write me a comment, if you have any questions.

If you liked the post, feel free to share it.

Anyway, the post is finished, have a good day and we will see next week!

From Zephyro it’s all, Bye!

Categories: Learn Java

Leave a Reply

%d bloggers like this: