I want to connect to a remote Windows desktop machine from a local machine with a Java program.
I have to check the disk space and several other services on the remo
You could install an SSH server on your remote desktop and you can write a Java program using jcraft and jsch libraries on your local machine to make an SSH connection to your remote desktop.
Remote Desktop Connection
Java
// Creating credentials
Process p = Runtime.getRuntime().exec("cmdkey /generic:" + ip +
" /user:" + userName +
" /pass:" + password);
p.destroy();
Runtime.getRuntime().exec("mstsc /v: " + ip + " /f /console");
Thread.sleep(2*60*1000); // Minutes seconds milliseconds
// Deleting credentials
Process p1 = Runtime.getRuntime().exec("cmdkey /delete:" + ip);
p1.destroy();
Command line
C:> cmdkey /generic:192.168.0.11 /user:XXXXX /pass:XXXXX
CMDKEY: Credential added successfully.
C:> mstsc.exe /v:192.168.0.11 /w:800 /h:600
Connecting to Remote Desktop.
C:> cmdkey /delete:192.168.0.11
CMDKEY: Credential deleted successfully.
You could also consider an RDP Java solution.
There are a lot of solutions out there. Check them out on Comparison of Java Remote Desktop projects.
The answer depends upon what operating system your local machine (host) is using to connect to your remote target Windows box.
If it is a Unix-based box, I would recommend using the open source library j-Interop.
Note, that you may need to manually modify the registry on the target box, so it can work correctly (make sure you peruse the FAQs of the project's website). If you find weird issues (exceptions thrown while connecting), here's a good article that helped me resolve them: Windows slaves fail to start via DCOM
On the other hand, if you are using a Windows box as your host, then your life will be much easier. I would recommend using:
Note that all of the above are opensource projects.
The freeware version out there as mentioned above is j-Integra, but I never tried using it.