Runtime rn = Runtime.getRuntime();
Process p = null;
try
{
p = rn.exec("c:/显示桌面.scf");
}
catch(IOException e)
{
e.printStackTrace();
}
try
{
p.wait(0xdbba0L);
}
catch(InterruptedException e)
{
e.printStackTrace();
}
下面是闹钟的实例:
import java.io.IOException;
public class Clock extends Thread
{
public Clock()
{
}
public void run()
{
do
try
{
System.out.println("\u5F00\u59CB\u8BA1\u65F6!");
for(int i = 0; i < 2; i++)
{
Thread.sleep(60000L);
System.out.println("\u7B2C" + (i + 1) + "\u5206\u949F\u8FC7\u53BB\u4E86.");
}
wake();
Thread.sleep(0x493e0L);
}
catch(InterruptedException e)
{
e.printStackTrace();
}
while(true);
}
public void wake()
{
System.out.println("\u4F11\u606F\u7684\u65F6\u95F4\u5230\u4E86!");
Runtime rn = Runtime.getRuntime();
Process p = null;
try
{
p = rn.exec("c:/显示桌面.scf");
}
catch(IOException e)
{
e.printStackTrace();
}
try
{
p.wait(0xdbba0L);
}
catch(InterruptedException e)
{
e.printStackTrace();
}
}
public static void main(String args[])
{
Clock ft = new Clock();
Thread t = new Thread(ft);
t.start();
}
}