I understand that this is not directly under Windows, but given the nature of Java, it can still work.
On Linux, there is a program called Netem, which, given that your java code, may work. I have never used it, so I canβt confirm its capabilities or use it, but there are usage examples here . You can quite trivially run Linux inside a virtual machine (for example, free (both in beer and in the form of free speech that you enjoy in the UK) VirtualBox) and, hopefully, your Java application inside that.
It may not be perfect and regret the general lack of know-how, but it can work for what you need
source share