public void init() throws URISyntaxException { String path = new File( WindowsService.class.getProtectionDomain().getCodeSource().getLocation().toURI()).getParent(); POSIXFactory.getPOSIX().chdir(path); System.setProperty("user.dir", path); serviceMain = new ServiceMain(); SERVICE_TABLE_ENTRY entry = new SERVICE_TABLE_ENTRY(); entry.lpServiceName = serviceName; entry.lpServiceProc = serviceMain; Advapi32.INSTANCE.StartServiceCtrlDispatcher((SERVICE_TABLE_ENTRY[]) entry.toArray(2)); }