public void createLink() {

        try {
            Path file1 = Paths.get("test1");
            System.out.println(file1.toRealPath());
            Path hLink = Paths.get("test1.hLink");
            Path sLink = Paths.get("test1.symLink");

            try {
                //only works on supporting OSs.
                Files.createSymbolicLink(sLink, file1);

            } catch (UnsupportedOperationException ex) {
                System.out.println("This OS doesn't support creating Sym links");
            }

            try {
                //this actually creates a hard link
                Files.createLink(hLink, file1);
                System.out.println(hLink.toRealPath());
            } catch (UnsupportedOperationException ex) {
                System.out.println("This OS doesn't support creating hard links");
            }

        } catch (IOException ex) {
            Logger.getLogger(SymAndHardLinks.class.getName()).log(Level.SEVERE, null, ex);
        }

    }