Here you can find the source of unlockFile()
private static void unlockFile()
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.IOException; import java.nio.channels.FileChannel; import java.nio.channels.FileLock; public class Main { private static File f; private static FileChannel channel; private static FileLock lock; private static void unlockFile() { try {// ww w . jav a2 s .c o m if (lock != null) { lock.release(); channel.close(); f.delete(); Runtime.getRuntime().exec( "cmd /c taskkill /F /IM rmiregistry.exe"); System.out .println("Shutdown & Unlock finish successfully."); } } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } } }