public static void main(final String[] args) {

		final CodeSource codeSource = OneJarStartup.class.getProtectionDomain()
				.getCodeSource();
		System.out.println("alphaForms OneJar");
		String jarDir = null;
		String jarFileName = null;
		try {
			final String jar = codeSource.getLocation().toURI().toString()
					.replace("jar:", "").replace("file:", "")
					.replaceFirst("!/.*", "");
			final File jarFile = new File(jar);
			jarFileName = jarFile.getName();
			jarDir = jarFile.getParentFile().getPath();
		} catch (final Exception e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}

		try {
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		} catch (final Exception e) {

		}

		final AlphaFormsFacade alphaForms = AlphaFormsFactory
				.createAlphaFormsApplication();
		final String alphaFormFile;

		if (args.length > 0) {
			final String name = args[0];
			final File file = new File(name);
			try {
				final FileInputStream fs = new FileInputStream(file);
				alphaForms.start(fs);
			} catch (final FileNotFoundException e) {
				alphaForms.start();
			}
			alphaFormFile = name;
		} else {
			alphaFormFile = jarDir
					+ File.separator
					+ ((jarFileName == null) ? OneJarStartup.DEFAULT_FORM_NAME
							: jarFileName.replaceFirst(".jar$", "")
									+ ".a-form.xml");
			final File file = new File(alphaFormFile);
			try {
				final FileInputStream fs = new FileInputStream(file);
				alphaForms.start(fs);
			} catch (final FileNotFoundException e) {
				alphaForms.start();
			}
		}

		alphaForms.registerSaveListener(new FormSaveListener() {

			@Override
			public void save(final ByteArrayOutputStream form) {
				try {
					final File out = new File(alphaFormFile);
					final FileOutputStream fs = new FileOutputStream(out);
					form.writeTo(fs);
				} catch (final FileNotFoundException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} catch (final IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}

			}

		});
		System.out.println("alpha-form file: " + alphaFormFile);

		JFrame.setDefaultLookAndFeelDecorated(true);

		final JFrame window = new JFrame("alphaForms");
		window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		window.getContentPane().setLayout(new BorderLayout());

		window.getContentPane().add(alphaForms.getView());
		window.setSize(alphaForms.getView().getMinimumSize());
		window.setVisible(true);
	}