If you use Java, that means you are using LDAP to query Active Directory. What you want will not work using the default LDAP port.
However, if you query the Global Catalog on port 3268
using LDAP it is possible to retrieve cross-domain memberships.
EDIT: If this does not yield any results, either you need a Universal Group (not likely) or the GC needs to be set up properly.
EDIT2: Given that you do not have a GC, the only other option is to create a referral object in AD that points to the external domain. See http://support.microsoft.com/kb/241737 how to set this up.
You then have to configure your Java LDAP environment to follow referrals like this: env.put(Context.REFERRAL, "follow");
.