public static void main(String[] args) {
	Options options = new Options();
	options.addOption(OptionBuilder.withArgName("file").hasArg().withDescription("Used to enter path of configfile. Default file is endpoint.properties. NOTE: If the file is empty or does not exsist, a default config is created.").create("config"));
	options.addOption("h", "help", false, "displays this page");
	CommandLineParser parser = new PosixParser();
	Properties properties = new Properties();
	try {
	    /*
	     * parse default config shipped with jar
	     */
	    CommandLine cmd = parser.parse(options, args);

	    /*
	     * load default configuration
	     */
	    InputStream in = ServerEndpoint.class.getResourceAsStream("/endpoint.properties");
	    if (in == null) {
		throw new IOException("Unable to load default config from JAR. This should not happen.");
	    }
	    properties.load(in);
	    in.close();
	    log.debug("Loaded default config base: {}", properties.toString());
	    if (cmd.hasOption("help")) {
		printHelp(options);
		System.exit(0);
	    }

	    /*
	     * parse cutom config if exists, otherwise create default cfg
	     */
	    if (cmd.hasOption("config")) {
		File file = new File(cmd.getOptionValue("config", "endpoint.properties"));
		if (file.exists() && file.canRead() && file.isFile()) {
		    in = new FileInputStream(file);
		    properties.load(in);
		    log.debug("Loaded custom config from {}: {}", file.getAbsoluteFile(), properties);
		} else {
		    log.warn("Config file does not exsist. A default file will be created.");
		}
		FileWriter out = new FileWriter(file);
		properties.store(out, "Warning, this file is recreated on every startup to merge missing parameters.");
	    }

	    /*
	     * create and start endpoint
	     */
	    log.info("Config read successfull. Values are: {}", properties);
	    ServerEndpoint endpoint = new ServerEndpoint(properties);
	    Runtime.getRuntime().addShutdownHook(endpoint.getShutdownHook());
	    endpoint.start();
	} catch (IOException ex) {
	    log.error("Error while reading config.", ex);
	} catch (ParseException ex) {
	    log.error("Error while parsing commandline options: {}", ex.getMessage());
	    printHelp(options);
	    System.exit(1);
	}
    }