简体   繁体   English

当此代码为“系统相关”时,这意味着什么?

[英]What does it mean when this code is “System Dependent”?

I am asking regarding this post: How to Clear Console: Java我在问这篇文章: 如何清除控制台:Java

The accepted answer is for clearing the console in Java is:用于清除 Java 控制台的公认答案是:

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). (我的代表不允许我对帖子发表评论)。

It means that the command won't work on all systems.这意味着该命令不适用于所有系统。 cls is a command to clear a command window in Windows. cls是在 Windows 中清除命令窗口的命令。 But in Unix, for example, that's not a defined command.但是在 Unix 中,例如,这不是一个定义的命令。

$ cls
ksh: cls:  not found

That Java code depends on a cls command being available.该 Java 代码取决于可用的cls命令。

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.例如ls是一个 Linux/Unix 命令,它不会在 Windows 上运行,除非您确实安装了ls程序。 Equally dir is Windows based command.同样dir是基于 Windows 的命令。

This makes the statement "System Dependent", restricting it's execution ability to a single (family) of platforms...这使得声明“依赖于系统”,将其执行能力限制为单个(系列)平台......

Most likely because cls is a Windows/DOS command, and wouldn't work on other operating systems.很可能是因为cls是 Windows/DOS 命令,不能在其他操作系统上运行。

For example, in a Windows console, you'd clear your screen like so:例如,在 Windows 控制台中,您可以像这样清除屏幕:

C:\>cls

On, say, Unix, you'd use the clear command:例如,在 Unix 上,您可以使用clear命令:

$ clear

It means it will only work on certain platforms.这意味着它只能在某些平台上工作。 cls is a command specific to Windows platforms. cls是特定于 Windows 平台的命令。 The command will not work on Unix/Linux systems for example where the equivalent clear command is used to clear the screen该命令在 Unix/Linux 系统上不起作用,例如在使用等效的clear命令清除屏幕的情况下

System dependent means that it won't work on some platforms.系统相关意味着它在某些平台上不起作用。 cls will only work on Windows. cls仅适用于 Windows。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM