1

I am looking for simple solution for finding total disk space and available space of a remove machine using java program.

Please help

Update There are questions already similar to this with primarily focus on local machine. I was looking solution for remote machine.

devThoughts
  • 820
  • 1
  • 12
  • 18
  • 3
    Connect to the remote machine (ssh, telnet, ...), run `df` or something equivalent and parse the output –  Oct 15 '14 at 19:02
  • 1
    Why do you need to use Java? Are you expecting the Java app to run on your local machine, or on the remote machine? (... though, if it's running on the remote machine, then the information about it being a remote machine wouldn't really be relevant...) – Krease Oct 15 '14 at 19:04
  • 2
    You cannot find out *anything* about a remote machine without some form of cooperation from that machine. The key question here is the nature of the remote machine's participation in your endeavor. Knowing that, you can decide how to implement the local part. – John Bollinger Oct 15 '14 at 19:05
  • Well. I am developing a java program which needs to know the disk space of remote Linux server. My client program is supposed to transfer certain files by checking total space on a remote machine. – devThoughts Oct 15 '14 at 19:10
  • 1
    The solution discussed in the thread below holds good for a local machine but not Remote. Corrent me if i am wrong. http://stackoverflow.com/questions/1051295/how-to-find-how-much-disk-space-is-left-using-java – devThoughts Oct 15 '14 at 19:12
  • are you saying you trying to get the server information without doing anything on the remote machine?? – Morteza Adi Oct 15 '14 at 19:49

1 Answers1

2

The easiest way to get the remote machine information and also safe way to do is to SSH to the server from Java and get the necessary information from.

use JSch Library for SSH connection to server.

for an example look here

Community
  • 1
  • 1
Morteza Adi
  • 2,413
  • 2
  • 22
  • 37