how to get mysql username and password using java of the MySQL install on system.

what do you mean "how to get"? if you "need to get" the password and username, ask your DB admin.

i want to know which username and password has been assign to mysql software of system on which currently java application is executing.

how about: by asking the DB admin.
what you are asking now is: there is a database on which I have no rights. how do I find a valid username and password for it. looks a lot like trying to 'break' into a secured DB.

actually i am making a application to backup and restore mysql database, for that i have to accept username and password of mysql to execute mysql command.
So, is there any other way to compare user entered username and password with existing mysql username and password.

have you checked the mysql db's configuration itself?
here you'll find an example of how to login in mysql through java.

if you actually get logged in, you know you have the right data, if not, try other data.

here is some more information on what you're dealing with. I assume you understand that the creators of MySQL were smart enough not to create a password system that would be hacked with the least bit of effort.