1

I am asking regarding this post: How to Clear Console: Java

The accepted answer is for clearing the console in Java is:

Runtime.getRuntime().exec("cls");

However, the poster mentioned that this code will be "system dependent". What does the poster mean by this?

(my rep does not allow me to comment on the post).

braX
  • 10,905
  • 5
  • 18
  • 32

5 Answers5

6

It means that the command won't work on all systems. cls is a command to clear a command window in Windows. But in Unix, for example, that's not a defined command.

$ cls
ksh: cls:  not found

That Java code depends on a cls command being available.

rgettman
  • 172,063
  • 28
  • 262
  • 343
  • So essentially, Java utilizes the OS's commands to clear its own console? So is the Java console an "extension" of the OS console? – Jukebocks77 Mar 06 '14 at 23:12
  • No, this Java code runs an external (to Java) process called "cls", which happens to clear the console in Windows (the console is not owned by Java). – rgettman Mar 06 '14 at 23:14
  • Right, I come from computer hardware and "system" has a much different meaning. Excuse my newbiness :p – Jukebocks77 Mar 07 '14 at 03:11
2

It means that the command is reliant on the current platform to support it. For example ls is a Linux/Unix command, which won't run on Windows, unless you actually have a ls program installed. Equally dir is Windows based command.

This makes the statement "System Dependent", restricting it's execution ability to a single (family) of platforms...

MadProgrammer
  • 336,120
  • 22
  • 219
  • 344
2

Most likely because cls is a Windows/DOS command, and wouldn't work on other operating systems.

For example, in a Windows console, you'd clear your screen like so:

C:\>cls

On, say, Unix, you'd use the clear command:

$ clear
Mike Christensen
  • 82,887
  • 49
  • 201
  • 310
1

It means it will only work on certain platforms. cls is a command specific to Windows platforms. The command will not work on Unix/Linux systems for example where the equivalent clear command is used to clear the screen

Reimeus
  • 155,977
  • 14
  • 207
  • 269
0

System dependent means that it won't work on some platforms. cls will only work on Windows.

Epic
  • 115
  • 12