InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("user.properties"); Properties p = new Properties(); try { p.load(inputStream); String theUserpass=p.getProperty(username); if (theUserpass!=null && theUserpass.equals(password)){ return true; }else{ return false; } } catch (IOException e1) { e1.printStackTrace(); }finally{ if (inputStream!=null){ try { inputStream.close(); } catch (IOException e) { } } }