-1

I come from a C/Linux background and don't have much background in Java. I generally develop system administrator utilities like :

  • disk cleanup
  • retrieve lost data / files
  • repairing file systems
  • disk de-fragmentation

I also develop Network monitoring security applications which help admins monitor : - their networks, - scan incoming & outgoing data packets, - remotely block ports / USBs - monitor emails with attachments etc

Right now we write code in C for Linux which has to be ported to windows but such a problem will not exist in Java.

My questions are :

  • Is Java the right language for writing these applications & utilities (as mentioned above)?

  • I understand Java will provide Libraries and classes to access system resources / network / sockets but will Java abstraction be a hindrance at some point (which would restrict the flexibility which C/C++ provide )?

  • If for example I want to write a utility to repair a file system / or retrieve data for Windows & Unix ...will I be using same API for both OS or there are different API for different OS?

I am not concerned about the speed / execution trade off since none of my applications have to make real time decisions as in the gaming industry.

mhlz
  • 3,497
  • 2
  • 23
  • 35

2 Answers2

0

Java is the right language if you want portability. You can do almost everything you can do with C/C++ and you can utilize patterns and libraries that help you create great maintainable designs. In case there is something very low level you cannot do with Java, you always can create your own native code that is loaded with Java Native Interface. Thus the only non-portable code you will have will be these native-code libraries.

rodolk
  • 5,606
  • 3
  • 28
  • 34
  • Thanks for your response. I generally develop programs like disk cleanup,retrieve lost data / files,repairing file systems,disk de-fragmentation and network scanning & monitoring. Will all of these be possible in Java and work as efficiently as the work in C/C++ – Sam Anderson Jul 23 '15 at 15:14
  • @SamAnderson, "as efficiently as", with C/C++ you are always faster. Sometimes that time difference does not pay off. In the tasks you are mentioning Java can do it very well. Remember Java is used even for embedded systems. In monitoring and network scanning you can do it with Java for sure. Repairing file system you just have to google for the proper interfaces and you will find what you need or do it using JNI. – rodolk Jul 23 '15 at 15:42
0

Right now we write code in C for Linux which has to be ported to windows but such a problem will not exist in Java.

Java can abstract away only so much since in the end, low level stuff always boils down to making system calls, which are different between OSes.

As long as you're working with pure java logic, or simple operating system utilities, you'll be golden. You want to open a TCP socket and connect to google.com? No problem. You want to open a file in a known location, read some lines, process them, and write the results to a different file? No problem, Java has you covered.

But, if you want to do more low-level stuff with Java, you'll run into trouble pretty soon. You want to open a raw socket and send a TCP packet? You can't, windows doesn't allow that. You want to get a file's creation time on Linux? You can't, Linux doesn't keep that information. Java's BasicFileAttributes.creationTime() will return a file's modification time on Linux. You want to get a nanosecond resolution timestamp? Well, you can, but only on some OSes. Or say you want to get the computer's hostname without resorting to a network lookup (which depends on a network being actually available), well, get ready for some hacking (this is my own answer by the way).

Now, to your more specific questions:

Is Java the right language for writing these applications & utilities (as mentioned above)?

I frankly don't know. I never tried defragmenting or restoring a file programmatically from Java. But since it involves some very low level filesystem operations, I suggest you do some serious reading before moving to Java. Check whether the APIs you need exist in the language itself or in some good libraries.

I understand Java will provide Libraries and classes to access system resources / network / sockets but will Java abstraction be a hindrance at some point (which would restrict the flexibility which C/C++ provide )?

Yes. For instance, it's impossible to open a raw socket using pure Java. And if I recall correctly, it's also impossible to set some socket options.

If for example I want to write a utility to repair a file system / or retrieve data for Windows & Unix ...will I be using same API for both OS or there are different API for different OS?

I never tried repairing a file system in Java, so I can't tell you about the APIs involved. But I find it hard to believe you'll find a pure Java api for doing low level stuff with the file system. You'll probably have to write your own native code (and run it through JNI) or use someone else's library (which probably uses JNI, like the raw socket library I mentioned earlier).

Community
  • 1
  • 1
Malt
  • 28,965
  • 9
  • 65
  • 105