List of usage examples for java.lang Throwable printStackTrace
public void printStackTrace()
From source file:net.pms.PMS.java
public static void main(String args[]) throws IOException, ConfigurationException { boolean displayProfileChooser = false; // FIXME (breaking change): use a standard argument // format (and a standard argument processor) e.g. // --console, --scrollbars &c. if (args.length > 0) { for (int a = 0; a < args.length; a++) { if (args[a].equals(CONSOLE)) { System.setProperty(CONSOLE, Boolean.toString(true)); } else if (args[a].equals(NATIVELOOK)) { System.setProperty(NATIVELOOK, Boolean.toString(true)); } else if (args[a].equals(SCROLLBARS)) { System.setProperty(SCROLLBARS, Boolean.toString(true)); } else if (args[a].equals(NOCONSOLE)) { System.setProperty(NOCONSOLE, Boolean.toString(true)); } else if (args[a].equals(PROFILES)) { displayProfileChooser = true; }/*from w w w . j av a 2 s.com*/ } } try { Toolkit.getDefaultToolkit(); if (isHeadless()) { if (System.getProperty(NOCONSOLE) == null) { System.setProperty(CONSOLE, Boolean.toString(true)); } } } catch (Throwable t) { System.err.println("Toolkit error: " + t.getClass().getName() + ": " + t.getMessage()); if (System.getProperty(NOCONSOLE) == null) { System.setProperty(CONSOLE, Boolean.toString(true)); } } if (!isHeadless() && displayProfileChooser) { ProfileChooser.display(); } try { setConfiguration(new PmsConfiguration()); assert getConfiguration() != null; // Load the (optional) logback config file. // This has to be called after 'new PmsConfiguration' // as the logging starts immediately and some filters // need the PmsConfiguration. // XXX not sure this is (still) true: the only filter // we use is ch.qos.logback.classic.filter.ThresholdFilter LoggingConfigFileLoader.load(); // create the PMS instance returned by get() createInstance(); // calls new() then init() } catch (Throwable t) { String errorMessage = String.format("Configuration error: %s: %s", t.getClass().getName(), t.getMessage()); System.err.println(errorMessage); t.printStackTrace(); if (!isHeadless() && instance != null) { JOptionPane.showMessageDialog( ((JFrame) (SwingUtilities.getWindowAncestor((Component) instance.getFrame()))), errorMessage, Messages.getString("PMS.42"), JOptionPane.ERROR_MESSAGE); } } }
From source file:com.nikonhacker.gui.EmulatorUI.java
public static void main(String[] args) throws EmulationException, IOException, ClassNotFoundException, UnsupportedLookAndFeelException, IllegalAccessException, InstantiationException { // Workaround for JDK bug - https://code.google.com/p/nikon-firmware-tools/issues/detail?id=17 System.setProperty("java.util.Arrays.useLegacyMergeSort", "true"); if (args.length > 0) { imageFile[Constants.CHIP_FR] = new File(args[0]); if (args.length > 1) { imageFile[Constants.CHIP_TX] = new File(args[1]); }/*from www . ja va 2 s . co m*/ } initProgrammableTimerAnimationIcons(BUTTON_SIZE_SMALL); // a lot of calls are made from GUI in AWT thread that exits fast with no error code Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { public void uncaughtException(Thread t, Throwable e) { e.printStackTrace(); System.exit(1); } }); //Schedule a job for the event-dispatching thread: //creating and showing this application's GUI. SwingUtilities.invokeLater(new Runnable() { public void run() { createAndShowGUI(); } }); }
From source file:focusedCrawler.util.parser.PaginaURL.java
/** * metodo para testes//from w w w. j a v a 2 s . c o m */ public static void main(String[] args) { try { long start = System.currentTimeMillis(); /* ParameterFile config = new ParameterFile(args[0].trim()); StopList st = new StopListArquivo(config.getParam("STOPLIST_FILES")); if( config.getParam("GERAR_SEM_ACENTO") != null ) { PaginaURL.GERAR_SEM_ACENTO = Boolean.valueOf(config.getParam("GERAR_SEM_ACENTO")).booleanValue(); } if( config.getParam("USAR_DESCRIPTION") != null ) { PaginaURL.USAR_DESCRIPTION = Boolean.valueOf(config.getParam("USAR_DESCRIPTION")).booleanValue(); } */ PaginaURL.USAR_DESCRIPTION = true; StopList st = null; try { st = new StopListArquivo(args[0]); } catch (Exception ioe) { } // StringBuffer content = new StringBuffer(); // BufferedReader input = new BufferedReader(new FileReader(new File( // args[1]))); // for (String line = input.readLine(); line != null; // line = input.readLine()) { // // content.append(line); // content.append("\n"); // // } // // String src = content.toString(); // PaginaURL p = new PaginaURL(new URL("http://www"), 0, 0, // src.length(), // src, st); PaginaURL p = new PaginaURL(args[1].trim(), st); System.out.println(p.toString()); // Vector<String> images = p.getImages(); // for (int i = 0; i < images.size(); i++) { // System.out.println(images.elementAt(i)); // } // System.out.println("USAR_DESCRIPTION = "+PaginaURL.USAR_DESCRIPTION); // long end = System.currentTimeMillis(); // // long time = end - start; //// System.out.println("URL:"); //// System.out.println("--"); //// System.out.println(p.endereco()); // System.out.println("Title:"); // System.out.println("--"); // System.out.println(p.titulo()); // System.out.println("Modified -> " + p.dataQueFoiModificado()); // System.out.println("Visited -> " + p.dataQueFoiVisitado()); // System.out.println("Paragraph:"); // System.out.println("--"); // System.out.println(p.paragrafo()); // System.out.println("Links:"); // System.out.println("--"); // URL[] links = p.links(); for (int i = 0; i < links.length; i++) { // String str = i + " = " + links[i]; System.out.println(links[i]); } // // String[] termos = p.palavras(); // int[] ocorrencias = p.ocorrencias(); // // System.out.println("Centroide:_SIZE("+termos.length+")"); // System.out.println("--"); // // String[] termosMeta = p.palavrasMeta(); // int[] ocorrenciasMeta = p.ocorrenciasMeta(); // // for (int i = 0; i < termos.length; i++) { // Enumeration posicoes_pos = p.posicoes(termos[i]); // String posicoes = "Nula"; // if( posicoes_pos != null ) { // posicoes = ""; // int c = 0; // while(posicoes_pos.hasMoreElements()) { // posicoes += (c == 0 ? "" : ",")+posicoes_pos.nextElement(); // c++; // } // } // String str = termos[i] + " = " + ocorrencias[i] + ", PL = "+posicoes; // // System.out.println(str); // } // System.out.println("\nMeta termos:"); // // for (int i = 0; i < termosMeta.length; i++) { // String str = termosMeta[i] + " = " + ocorrenciasMeta[i]; // // System.out.println(str); // } // // System.out.println("Palavras[" + termos.length + "] em " // + p.endereco() + " tamanho do arquivo : " // + p.tamanhoDoArquivo()); // // Vector<HACCluster> vLinks = new Vector<HACCluster>(); // HashSet<String> uniqueURLs = new HashSet<String>(); LinkNeighborhood[] ln = p.getLinkNeighboor(); System.out.println("SIZE:" + ln.length); for (int i = 0; i < ln.length; i++) { System.out.println("URL:" + ln[i].getLink().toString()); System.out.println("ANC:" + ln[i].getAnchorString()); System.out.println("ARO:" + ln[i].getAroundString()); System.out.println("SRC:" + ln[i].getImgSrc()); System.out.println("ALT:" + ln[i].getAltString()); } // System.out.println(">>>>>>>>>>"+ln.length); // for (int i = 0; i < ln.length; i++) { // System.out.println("Title:" + p.titulo()); // if(!uniqueURLs.contains(ln[i].getLink().toString()) && !ln[i].getLink().getFile().equals("/")){ // uniqueURLs.add(ln[i].getLink().toString()); // }else{ // continue; // } // String[] anchor = ln[i].getAnchor(); // System.out.println(">>>URL:" + ln[i].getLink().toString()); // System.out.println(">>>ANC:" + ln[i].getAnchorString()); // System.out.println(">>>ARO:" + ln[i].getAroundString()); // if(anchor.length > 3){ // System.out.println("URL:"+ln[i].getLink()); // String url = ln[i].getLink().toString(); // String normURL = url; // int index = url.indexOf("?"); // if(index != -1){ // if(!url.contains("gen") && !url.substring(index).contains("&")){ // normURL = url.substring(0,index); // } // } // index = normURL.indexOf("index.jsp"); // if(index != -1){ // normURL = normURL.substring(0,index); // // normURL = normURL.substring(0,normURL.length()-9); // } // index = normURL.indexOf("wtSlotClick"); // if(index != -1){ // normURL = normURL.substring(0,index) + normURL.substring(index+24); // } // URL url1 = new URL(normURL); // VSMVector point = new VSMVector(url1.getFile(), st); // // VSMVector point1 = new VSMVector(ln[i].getAnchorString(), st); // vLinks.add(new HACCluster(url1.getFile(), point, null)); // System.out.println("FILE:"+ln[i].getLink().getFile()); // // System.out.print("ANC: "); // // for (int j = 0; j < anchor.length; j++) { // System.out.print(anchor[j] + " "); // } // System.out.println(""); // } // System.out.println(""); // System.out.print("ARO: "); // String[] around = ln[i].getAround(); // for (int j = 0; j < around.length; j++) { // System.out.print(around[j] + " "); // } // System.out.println(""); // System.out.println("SOURCE:" + ln[i].getImgSrc()); // System.out.print("ALT: "); // if(ln[i].getImgAlt() != null){ // String[] imgAlt = ln[i].getImgAlt(); // for (int j = 0; j < imgAlt.length; j++) { // System.out.print(imgAlt[j] + " "); // } // } // } // } // System.exit(1); /* * URL url=new URL(args[0]); * System.out.println("URL = "+url); * URLConnection con = url.openConnection(); * System.out.println("getURL() = "+con.getURL()); * System.out.println("getContentType() = "+con.getContentType()); */ } catch (Throwable t) { t.printStackTrace(); } }
From source file:be.ibridge.kettle.spoon.Spoon.java
/** * This is the main procedure for Spoon. * /*from w w w . j a va 2s .c om*/ * @param a Arguments are available in the "Get System Info" step. */ public static void main(String[] a) throws KettleException { EnvUtil.environmentInit(); ArrayList args = new ArrayList(); for (int i = 0; i < a.length; i++) args.add(a[i]); Display display = new Display(); Splash splash = new Splash(display); StringBuffer optionRepname, optionUsername, optionPassword, optionJobname, optionTransname, optionFilename, optionDirname, optionLogfile, optionLoglevel; CommandLineOption options[] = new CommandLineOption[] { new CommandLineOption("rep", "Repository name", optionRepname = new StringBuffer()), new CommandLineOption("user", "Repository username", optionUsername = new StringBuffer()), new CommandLineOption("pass", "Repository password", optionPassword = new StringBuffer()), new CommandLineOption("job", "The name of the job to launch", optionJobname = new StringBuffer()), new CommandLineOption("trans", "The name of the transformation to launch", optionTransname = new StringBuffer()), new CommandLineOption("dir", "The directory (don't forget the leading /)", optionDirname = new StringBuffer()), new CommandLineOption("file", "The filename (Transformation in XML) to launch", optionFilename = new StringBuffer()), new CommandLineOption("level", "The logging level (Basic, Detailed, Debug, Rowlevel, Error, Nothing)", optionLoglevel = new StringBuffer()), new CommandLineOption("logfile", "The logging file to write to", optionLogfile = new StringBuffer()), new CommandLineOption("log", "The logging file to write to (deprecated)", optionLogfile = new StringBuffer(), false, true), }; // Parse the options... CommandLineOption.parseArguments(args, options); String kettleRepname = Const.getEnvironmentVariable("KETTLE_REPOSITORY", null); String kettleUsername = Const.getEnvironmentVariable("KETTLE_USER", null); String kettlePassword = Const.getEnvironmentVariable("KETTLE_PASSWORD", null); if (!Const.isEmpty(kettleRepname)) optionRepname = new StringBuffer(kettleRepname); if (!Const.isEmpty(kettleUsername)) optionUsername = new StringBuffer(kettleUsername); if (!Const.isEmpty(kettlePassword)) optionPassword = new StringBuffer(kettlePassword); // Before anything else, check the runtime version!!! String version = Const.JAVA_VERSION; if ("1.4".compareToIgnoreCase(version) > 0) { System.out.println("The System is running on Java version " + version); System.out.println("Unfortunately, it needs version 1.4 or higher to run."); return; } // Set default Locale: Locale.setDefault(Const.DEFAULT_LOCALE); LogWriter log; LogWriter.setConsoleAppenderDebug(); if (Const.isEmpty(optionLogfile)) { log = LogWriter.getInstance(Const.SPOON_LOG_FILE, false, LogWriter.LOG_LEVEL_BASIC); } else { log = LogWriter.getInstance(optionLogfile.toString(), true, LogWriter.LOG_LEVEL_BASIC); } if (log.getRealFilename() != null) log.logBasic(APP_NAME, Messages.getString("Spoon.Log.LoggingToFile") + log.getRealFilename());//"Logging goes to " if (!Const.isEmpty(optionLoglevel)) { log.setLogLevel(optionLoglevel.toString()); log.logBasic(APP_NAME, Messages.getString("Spoon.Log.LoggingAtLevel") + log.getLogLevelDesc());//"Logging is at level : " } /* Load the plugins etc.*/ StepLoader stloader = StepLoader.getInstance(); if (!stloader.read()) { log.logError(APP_NAME, Messages.getString("Spoon.Log.ErrorLoadingAndHaltSystem"));//Error loading steps & plugins... halting Spoon! return; } /* Load the plugins etc. we need to load jobentry*/ JobEntryLoader jeloader = JobEntryLoader.getInstance(); if (!jeloader.read()) { log.logError("Spoon", "Error loading job entries & plugins... halting Kitchen!"); return; } final Spoon spoon = new Spoon(log, display, null); staticSpoon = spoon; spoon.setDestroy(true); spoon.setArguments((String[]) args.toArray(new String[args.size()])); log.logBasic(APP_NAME, Messages.getString("Spoon.Log.MainWindowCreated"));//Main window is created. RepositoryMeta repositoryMeta = null; UserInfo userinfo = null; if (Const.isEmpty(optionRepname) && Const.isEmpty(optionFilename) && spoon.props.showRepositoriesDialogAtStartup()) { log.logBasic(APP_NAME, Messages.getString("Spoon.Log.AskingForRepository"));//"Asking for repository" int perms[] = new int[] { PermissionMeta.TYPE_PERMISSION_TRANSFORMATION, PermissionMeta.TYPE_PERMISSION_JOB }; splash.hide(); RepositoriesDialog rd = new RepositoriesDialog(spoon.disp, perms, Messages.getString("Spoon.Application.Name"));//"Spoon" if (rd.open()) { repositoryMeta = rd.getRepository(); userinfo = rd.getUser(); if (!userinfo.useTransformations()) { MessageBox mb = new MessageBox(spoon.shell, SWT.OK | SWT.ICON_ERROR); mb.setMessage(Messages.getString("Spoon.Dialog.RepositoryUserCannotWork.Message"));//"Sorry, this repository user can't work with transformations from the repository." mb.setText(Messages.getString("Spoon.Dialog.RepositoryUserCannotWork.Title"));//"Error!" mb.open(); userinfo = null; repositoryMeta = null; } } else { // Exit point: user pressed CANCEL! if (rd.isCancelled()) { splash.dispose(); spoon.quitFile(); return; } } } try { // Read kettle transformation specified on command-line? if (!Const.isEmpty(optionRepname) || !Const.isEmpty(optionFilename)) { if (!Const.isEmpty(optionRepname)) { RepositoriesMeta repsinfo = new RepositoriesMeta(log); if (repsinfo.readData()) { repositoryMeta = repsinfo.findRepository(optionRepname.toString()); if (repositoryMeta != null) { // Define and connect to the repository... spoon.rep = new Repository(log, repositoryMeta, userinfo); if (spoon.rep.connect(Messages.getString("Spoon.Application.Name")))//"Spoon" { if (Const.isEmpty(optionDirname)) optionDirname = new StringBuffer(RepositoryDirectory.DIRECTORY_SEPARATOR); // Check username, password spoon.rep.userinfo = new UserInfo(spoon.rep, optionUsername.toString(), optionPassword.toString()); if (spoon.rep.userinfo.getID() > 0) { // Options /file, /job and /trans are mutually exclusive int t = (Const.isEmpty(optionFilename) ? 0 : 1) + (Const.isEmpty(optionJobname) ? 0 : 1) + (Const.isEmpty(optionTransname) ? 0 : 1); if (t > 1) { log.logError(APP_NAME, Messages.getString("Spoon.Log.MutuallyExcusive")); // "More then one mutually exclusive options /file, /job and /trans are specified." } else if (t == 1) { if (!Const.isEmpty(optionFilename)) { spoon.openFile(optionFilename.toString(), false); } else { // OK, if we have a specified job or transformation, try to load it... // If not, keep the repository logged in. RepositoryDirectory repdir = spoon.rep.getDirectoryTree() .findDirectory(optionDirname.toString()); if (repdir == null) { log.logError(APP_NAME, Messages.getString( "Spoon.Log.UnableFindDirectory", optionDirname.toString())); //"Can't find directory ["+dirname+"] in the repository." } else { if (!Const.isEmpty(optionTransname)) { TransMeta transMeta = new TransMeta(spoon.rep, optionTransname.toString(), repdir); transMeta.setFilename(optionRepname.toString()); transMeta.clearChanged(); spoon.addSpoonGraph(transMeta); } else { // Try to load a specified job if any JobMeta jobMeta = new JobMeta(log, spoon.rep, optionJobname.toString(), repdir); jobMeta.setFilename(optionRepname.toString()); jobMeta.clearChanged(); spoon.addChefGraph(jobMeta); } } } } } else { log.logError(APP_NAME, Messages.getString("Spoon.Log.UnableVerifyUser"));//"Can't verify username and password." spoon.rep.disconnect(); spoon.rep = null; } } else { log.logError(APP_NAME, Messages.getString("Spoon.Log.UnableConnectToRepository"));//"Can't connect to the repository." } } else { log.logError(APP_NAME, Messages.getString("Spoon.Log.NoRepositoryRrovided"));//"No repository provided, can't load transformation." } } else { log.logError(APP_NAME, Messages.getString("Spoon.Log.NoRepositoriesDefined"));//"No repositories defined on this system." } } else if (!Const.isEmpty(optionFilename)) { spoon.openFile(optionFilename.toString(), false); } } else // Normal operations, nothing on the commandline... { // Can we connect to the repository? if (repositoryMeta != null && userinfo != null) { spoon.rep = new Repository(log, repositoryMeta, userinfo); if (!spoon.rep.connect(Messages.getString("Spoon.Application.Name"))) //"Spoon" { spoon.rep = null; } } if (spoon.props.openLastFile()) { log.logDetailed(APP_NAME, Messages.getString("Spoon.Log.TryingOpenLastUsedFile"));//"Trying to open the last file used." List lastUsedFiles = spoon.props.getLastUsedFiles(); if (lastUsedFiles.size() > 0) { LastUsedFile lastUsedFile = (LastUsedFile) lastUsedFiles.get(0); spoon.loadLastUsedFile(lastUsedFile, repositoryMeta); } } } } catch (KettleException ke) { log.logError(APP_NAME, Messages.getString("Spoon.Log.ErrorOccurred") + Const.CR + ke.getMessage());//"An error occurred: " spoon.rep = null; // ke.printStackTrace(); } spoon.open(); splash.dispose(); try { while (!spoon.isDisposed()) { if (!spoon.readAndDispatch()) spoon.sleep(); } } catch (Throwable e) { log.logError(APP_NAME, Messages.getString("Spoon.Log.UnexpectedErrorOccurred") + Const.CR + e.getMessage());//"An unexpected error occurred in Spoon: probable cause: please close all windows before stopping Spoon! " e.printStackTrace(); } spoon.dispose(); log.logBasic(APP_NAME, APP_NAME + " " + Messages.getString("Spoon.Log.AppHasEnded"));//" has ended." // Close the logfile log.close(); // Kill all remaining things in this VM! System.exit(0); }
From source file:Main.java
public static void handleException(Context context, Throwable e) { e.printStackTrace(); // for debug }
From source file:Main.java
private static final void handleError(Throwable ex) { ex.printStackTrace(); // ... handle error here... }
From source file:Main.java
public static void dropTable(SQLiteDatabase db, String tab) { try {/* w w w.j av a2s.c o m*/ db.execSQL(new StringBuilder(64).append("DROP TABLE IF EXISTS ").append(tab).append(';').toString()); } catch (Throwable e) { e.printStackTrace(); } }
From source file:Main.java
/** * Sleep thread without exception.//from ww w . j a va2 s. c o m * * @param millis */ public static void sleep(long millis) { try { Thread.sleep(millis); } catch (Throwable e) { e.printStackTrace(); } }
From source file:Main.java
public static void showException(Activity activity, String msg, Throwable e) { e.printStackTrace(); String s = String.format("%s: %s", msg, e.getMessage()); showToast(activity, s);/*from w w w . jav a 2 s . co m*/ Log.e(TAG, s); }
From source file:Main.java
public static void closeInputMethodWindow(Activity activity) { try {/*from ww w.j av a2 s .c o m*/ ((InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow( activity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } catch (Throwable th) { th.printStackTrace(); } }