Yes, you can connect with a GMSA account - but only if you log on to Windows with that account. (Which would imply that your Java program is running as a service.)
When you log with Window authentication, you first need to log on Windows with that Windows user. You cannot log on SQL Server with a different Windows user.