How to set Dgraph server account password access

How to set Dgraph server account password access,and How can A Java client access it using an account password

Do you mean to use ACL?
If yes, there is a login method on both DgraphClient and DgraphAsyncClient in Java client.
Also, you can look at dgraph acl command to find out how to create user, change password etc.
Here are the ACL docs: https://dgraph.io/docs/enterprise-features/#turn-on-acls

By the way, ACL is an enterprise only feature.

As mentioned here Enterprise Features, Dgraph Core Values, Open Source, and My Thoughts - #12 by mrjn

You can use “Poor Man’s ACL”. which is open source. But ACL can be better for some cases.