用java实现在命令方式清屏
java实现清屏功能
1. 编写一个类ClearScreen.java
public class ClearScreen{
Static
{
loadLibrary("Clear");
}
public native static void clearScreen();
public static void main(String[] args){
clearScreen();
}
}
2. javac ClearScreen.java -> ClearScreen.class
3. javah ClearScreen -> ClearScreen.h
4. 编写ClearScreen.cpp实现native方法clearScreen();
#include <<FONT face=Arial>jawt_md.h >
#include "ClearScreen.h"
#include
JNIEXPORT VOID JNICALL Java_ClearScreen_clearScreen(JNIEnv *, jclass)
{
system("cls");
}
5.安装一个microsoft compiler 编译ClearScreen.cpp,得到Clear.dll
注意:将Jdk安装环境include目录下的jawt_md.h jni_md.h jni.h jawt.h 4 个头文件copy到 Microsoft Visual Studio的include目录下
cl -LD ClearScreen.cpp -FeClear.dll
其中 -LD create .dll -Fe name executable file
java实现清屏功能
1. 编写一个类ClearScreen.java
public class ClearScreen{
Static
{
loadLibrary("Clear");
}
public native static void clearScreen();
public static void main(String[] args){
clearScreen();
}
}
2. javac ClearScreen.java -> ClearScreen.class
3. javah ClearScreen -> ClearScreen.h
4. 编写ClearScreen.cpp实现native方法clearScreen();
#include <<FONT face=Arial>jawt_md.h
#include "ClearScreen.h"
#include
JNIEXPORT VOID JNICALL Java_ClearScreen_clearScreen(JNIEnv *, jclass)
{
system("cls");
}
5.安装一个microsoft compiler 编译ClearScreen.cpp,得到Clear.dll
注意:将Jdk安装环境include目录下的jawt_md.h
cl -LD ClearScreen.cpp -FeClear.dll
其中 -LD create .dll -Fe name executable file