TavernerPOS - Source Code
Clone:
git clone http://www.librarysmith.co.uk/tavernerPOS
package com.floreantpos.main;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import org.apache.commons.cli.BasicParser;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.Options;
public class Main {
private static final String DEVELOPMENT_MODE = "developmentMode"; //$NON-NLS-1$
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
Options options = new Options();
options.addOption(DEVELOPMENT_MODE, true, "State if this is developmentMode"); //$NON-NLS-1$
CommandLineParser parser = new BasicParser();
CommandLine commandLine = parser.parse(options, args);
String optionValue = commandLine.getOptionValue(DEVELOPMENT_MODE);
Application application = Application.getInstance();
if (optionValue != null) {
application.setDevelopmentMode(Boolean.valueOf(optionValue));
}
application.start();
}
public static void restart() throws IOException, InterruptedException, URISyntaxException {
final String javaBin = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
final File currentJar = new File(Main.class.getProtectionDomain().getCodeSource().getLocation().toURI());
/* is it a jar file? */
if (!currentJar.getName().endsWith(".jar")) //$NON-NLS-1$
return;
/* Build command: java -jar application.jar */
final ArrayList<String> command = new ArrayList<String>();
command.add(javaBin);
command.add("-jar"); //$NON-NLS-1$
command.add(currentJar.getPath());
final ProcessBuilder builder = new ProcessBuilder(command);
builder.start();
System.exit(0);
}
}
- Details
- Last Updated: Monday, 04 April 2016 02:04
- Hits: 35969839