Have you tried just using tcpdump -i <interface name> -vv port 53
it will capture all dns coming from the server, depending on what you have running, that may work.
Are you able to set the interface or IP that the java program uses? If you can then you can use filters on tcpdump to restrict to just that IP.
If you need to add another IP to an interface, ip add 192.168.55.55/32 dev eth0
replacing the ip and dev name to match your setup.
If you can set the interface, you can also create a private vlan by:
ip link add link eth0 <name of link> type vlan id 10
changing the id and interface to match your setup. If you need external access for the program, sysctl net.ipv4.conf.eth0.forwarding
this will enable forwarding on your interface for the current session, if you set the IP for the link as a /32 address, then the forwarding should work.
Similar to a link, add a tap device ip link add link eth0 <name of tap> type tap
and the same applies above with forwarding and IP address.
If you can get it on its own ip or interface then:
own interface: tcpdump -i <interface name> -n -p -vv port 53
the -n will stop dns lookups and display the results quicker, and the -p stops promisc (receives all packets on the physical interface even if it not mode that is default for tcpdump and finally -vv for verbose so it shows the data in the packet.
own IP: tcpdump -i <interface name> -n -p port 53 host <ip address>
with the IP being the ip for the java program and interface to match your local setup.