There is a way - using a native method, but it's a bit long winded and you need a C++ compiler.
Say you have a class called ClearScreen:
Code:
public class ClearScreen {
static {
System.loadLibrary("Clear");
}
public native static void clearScreen();
public static void main(String[] args) {
clearScreen();
}
}
The native method clearScreen will be implemented in C++ and the dll file Clear.dll (create it in a second) will be loaded by the runtime system when the class is loaded.
Now compile ClearScreen: "javac ClearScreen.java"
Now generate the appropriate .h file: "javah ClearScreen"
Now you can create the implementation for the clearScreen method:
Code:
#include <jni.h>
#include "ClearScreen.h"
#include <stdlib.h>
JNIEXPORT void JNICALL Java_ClearScreen_clearScreen(JNIEnv *, jclass)
{
system("cls");
}
Save that in a file called say ClearScreen.cpp.
Now compile your .dll file: "cl -IC:\j2sdk1.4.2\include -IC:\j2sdk1.4.2\include\win32 -LD ClearScreen.cpp -FeClear.dll" (assuming you have a microsoft compiler).
Change your include folders to match your setup.
Now hopefully when you run the program "java ClearScreen" it should work.
Might be no good to you because it uses another language.