I found the solution. So the link above really works - the installation was proper. I had to go through the logs /var/log/janusgraph . Found out a java error there. So I got to know that if you install java using Ambari's automatic install, it does not sets up the environment variable in your pc. So I followed these steps:-
Open /etc/environment in a text editor and add the
following line:
JAVA_HOME="/usr/jdk64/jdk1.8.0_112/”
Use source to load the variable by running:-
source /etc/environment
Then restart JanusGraph. It works perfectly this time.