Java – for Windows 7, what is runtime getruntime(). Exec (“domain specific equivalent CLS”)
•
Java
I want to clear the screen in my java application. After reading a lot of questions and Google search, I found the following code
runtime.getruntime().exec("cls")
or
Runtime.getRuntime().exec("cmd /c cls");
But the above code does not work in Windows 7 I know the "CLS" script is domain specific. Who knows what text I should use in Windows 7 This will be very useful, thank you in advance
Solution
I realize that you are looking for an easy way to clear the screen You will have to use line feed hackers or
//------------------------------------------ // Java2Win.class //------------------------------------------ public interface Java2Win extends Library { Java2Win java2Win = (Java2Win)Native.loadLibrary("Java2Win64",Java2Win.class); void cls(); } //------------------------------------------ //------------------------------------------ // Java2Win.c (Java2Win.dll & Java2Win64.dll) //------------------------------------------ JNIEXPORT void cls() { system("cls"); } //------------------------------------------ //------------------------------------------ // Test //------------------------------------------ public static void main(final String args[]) throws Exception { final File file = new File("rootToDLL","Java2Win64.dll"); LibraryLoader.loadLibrary(file); System.out.println("-----some output"); System.out.println("-----some output"); System.out.println("-----some output"); Thread.sleep(2000); Java2Win.java2Win.cls(); System.out.println("-----cleared"); } //------------------------------------------
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码