How to setup java enviroment on server

Just to generalize all that I studied from administration field, I decided to write all steps needed to setup your java environment on the web.

What will we need?

Server/local machine.Say, you need to deploy your app on the web and you need a server. I will be using digitalocean for that purpose. Of course, you will need ssh access.
Java Development Kit. I will be using jdk 1.7
Maven build tool. For building apps. We can setup as much tools, as we want(Ant, Gradle), I choosed maven because I use it in my daily development.
Setting up ssh key

If you already have ssh key , then you are free to skip this part.

Go to your terminal and type

ssh-keygen -t rsa

You will be asked to enter ssh key location - I choosed

~/.ssh/id_rsa_example

After that, executed:

cat ~/.ssh/id_rsa_example.pub

You will get public key, that you need to store in your digitalocean instance in SSH page

Name this ssh and copy output from previous cat procedure.

PS - Adding your ssh to digitalocean menu means, that when you will create server instance and choose that ssh key in wizard - it will automatically appear in server instance ~/.ssh/authorized_keys.

PS - if you will forget to attach your ssh key to appropriate droplet you can always add this ssh key manually by typing