Installing Go on Ubuntu is pretty easy. We can do that with apt-get manager but i preffer to do it with downloading from official site.
Last version of the time of writing this is 1.5. So we can download it from https://golang.org/dl/
curl -O https://storage.googleapis.com/golang/go1.5.linux-amd64.tar.gz
After that we must unpack it into
/usr/local

tar -C /usr/local -xzf go1.5.linux-amd64.tar.gz

After that we must set some
env
variables.
mkdir -p ~/go
echo "export GOPATH=$HOME/go" >> ~/.bashrc
echo "export PATH=$PATH:$HOME/go/bin:/usr/local/go/bin" >> ~/.bashrc
source ~/.bashrc
And finally we have it:
public class Main {
    public static void main(String[] args) {
        System.out.println("Hello, world!");
    }
}