Example usage for java.lang System gc

List of usage examples for java.lang System gc

Introduction

In this page you can find the example usage for java.lang System gc.

Prototype

public static void gc() 

Source Link

Document

Runs the garbage collector in the Java Virtual Machine.

Usage

From source file:edu.isi.karma.kr2rml.KR2RMLWorksheetRDFGenerator.java

public void generateRDF(boolean closeWriterAfterGeneration) throws IOException {
    // Prepare the output writer
    BufferedWriter bw = null;/*from  ww w .ja  va2s . c om*/
    try {
        if (this.outWriter == null && this.outputFileName != null) {
            bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(this.outputFileName), "UTF-8"));
            outWriter = new PrintWriter(bw);
        } else if (this.outWriter == null && this.outputFileName == null) {
            outWriter = new PrintWriter(System.out);
        }

        // RDF Generation starts at the top level rows
        ArrayList<Row> rows = this.worksheet.getDataTable().getRows(0,
                this.worksheet.getDataTable().getNumRows());
        int i = 1;
        for (Row row : rows) {
            Set<String> rowTriplesSet = new HashSet<String>();
            Set<String> rowPredicatesCovered = new HashSet<String>();
            Set<String> predicatesSuccessful = new HashSet<String>();
            Map<String, ReportMessage> predicatesFailed = new HashMap<String, ReportMessage>();
            generateTriplesForRow(row, rowTriplesSet, rowPredicatesCovered, predicatesFailed,
                    predicatesSuccessful);

            outWriter.println();
            if (i++ % 2000 == 0)
                logger.info("Done processing " + i + " rows");
            for (ReportMessage errMsg : predicatesFailed.values()) {
                this.errorReport.addReportMessage(errMsg);
            }
        }

        // Generate column provenance information if required
        if (addColumnContextInformation) {
            generateColumnProvenanceInformation();
        }

    } finally {
        if (closeWriterAfterGeneration) {
            outWriter.flush();
            outWriter.close();
            if (bw != null)
                bw.close();
        }
    }
    // An attempt to prevent an occasional error that occurs on Windows platform
    // The requested operation cannot be performed on a file with a user-mapped section open
    System.gc();
}

From source file:com.sec.ose.osi.sdk.protexsdk.bom.BOMReportAPIWrapper.java

public static ArrayList<IdentifiedFilesRow> getIdentifiedFilesFromBOMReport(String projectName,
        UIResponseObserver observer) {/*from  w  w  w.  j a  v  a2 s  . com*/

    log.debug("createIdentifiedFilewRowList");

    String msgHead = "Creating Identified Files Sheet: - " + projectName + "\n";
    observer.setMessageHeader(msgHead);

    // get Identified Files
    String pMessage = msgHead + " > Getting [Identified Files] information from server.\n";
    observer.pushMessage(pMessage);
    ReportEntityList identifiedFilesEntList = ReportAPIWrapper.getIdentifiedFiles(projectName, observer, true);
    if (identifiedFilesEntList == null)
        return null;
    if (identifiedFilesEntList.size() == 0)
        return null;

    // get Compare Code Matches
    pMessage = msgHead + " > Getting [Compare Code Matches] information from server.\n";
    observer.pushMessage(pMessage);
    ReportEntityList compareCodeMatches = ReportAPIWrapper.getCompareCodeMatches(projectName, observer, true);
    if (compareCodeMatches == null)
        return null;
    if (compareCodeMatches.size() == 0)
        return null;

    log.debug("create IdentifiedFilesRow");
    HashSet<String> duplicateCheckSet = new HashSet<String>();
    ArrayList<IdentifiedFilesRow> IdentifiedFilesRowList = new ArrayList<IdentifiedFilesRow>(
            identifiedFilesEntList.size());
    for (ReportEntity entity : identifiedFilesEntList) {

        String filePath = entity.getValue(ReportInfo.IDENTIFIED_FILES.FILE_FOLDER_NAME);
        String componentName = entity.getValue(ReportInfo.IDENTIFIED_FILES.COMPONENT);
        String componentVersion = entity.getValue(ReportInfo.IDENTIFIED_FILES.VERSION);
        String fileComment = entity.getValue(ReportInfo.IDENTIFIED_FILES.COMMENT);
        String fileLicense = parseFileLicense(entity.getValue(ReportInfo.IDENTIFIED_FILES.LICENSE));
        String discoveryType = entity.getValue(ReportInfo.IDENTIFIED_FILES.DISCOVERY_TYPE);

        if (componentName.equals("") && componentVersion.equals("") && fileLicense.equals("")) {
            continue;
        }

        String duplicateCheck = filePath + componentName + fileLicense;
        if (duplicateCheckSet.contains(duplicateCheck) == true) {
            continue;
        }

        duplicateCheckSet.add(duplicateCheck);
        IdentifiedFilesRowList.add(new IdentifiedFilesRow(projectName, filePath, componentName, fileLicense,
                discoveryType, fileComment));
    }

    log.debug("update code match info");
    HashMap<String, CodeMatchEnt> codeMatchInfoMap = new HashMap<String, CodeMatchEnt>(
            compareCodeMatches.size());
    for (ReportEntity entity : compareCodeMatches) {
        String fullPath = entity.getValue(ReportInfo.COMPARE_CODE_MATCHES.FULL_PATH);
        String codeMatchCnt = entity.getValue(ReportInfo.COMPARE_CODE_MATCHES.CODE_MATCH_COUNT);
        String url = entity.getValue(ReportInfo.COMPARE_CODE_MATCHES.COMPARE_CODE_MATCHES_LINK);

        url = url.replaceFirst("127.0.0.1", LoginSessionEnt.getInstance().getProtexServerIP());

        codeMatchInfoMap.put(fullPath, new CodeMatchEnt(fullPath, codeMatchCnt, url));
    }
    for (IdentifiedFilesRow fileEnt : IdentifiedFilesRowList) {
        CodeMatchEnt codeMatchEnt = codeMatchInfoMap.get(fileEnt.getFullPath());
        if (CODE_MATCH.equals(fileEnt.getDiscoveryType())) {
            fileEnt.setUrl(codeMatchEnt.url);
            fileEnt.setCodeMatchCnt(codeMatchEnt.codeMatchCnt);
        }
    }

    String msg = IdentifiedFilesRowList.size() + " files are loaded.";
    observer.pushMessage(msg);
    log.debug(msg);

    log.debug("start Garbage collector in BOMReportAPIWrapper");
    System.gc();
    log.debug("finish Garbage collector in BOMReportAPIWrapper");

    return IdentifiedFilesRowList;

}

From source file:core.performance.PerformanceJavaTHash.java

@Test
public void testWithIntegerKeys() {

    // TimeMeasure.begin("testWithIntegerKeys LoadReadExecutorWithoutMultiKey");
    // LoadReadExecutorWithoutMultiKey executorWithout = new LoadReadExecutorWithoutMultiKey(ITERATIONS_FOR_QUICK);
    ///*www  .j  a v a  2 s.c o m*/
    // {
    // for (int i = 0; i < 10; i++) {
    // TimeMeasure.begin("executeWithIntegerAndMapAndMultiThreading with HashMap" + i);
    // executorWithout.executeWithIntegerAndMapAndMultiThreading(new HashMap(ITERATIONS_FOR_QUICK));
    // TimeMeasure.end("executeWithIntegerAndMapAndMultiThreading with HashMap" + i);
    // }
    //
    // TimeMeasure.begin("executeWithIntegerAndMapAndMultiThreading with HashedMap");
    // executorWithout.executeWithIntegerAndMapAndMultiThreading(new HashedMap(ITERATIONS_FOR_QUICK));
    // TimeMeasure.end("executeWithIntegerAndMapAndMultiThreading with HashedMap");
    //
    // TimeMeasure.begin("executeWithIntegerAndMapAndMultiThreading with FastHashMap");
    // executorWithout.executeWithIntegerAndMapAndMultiThreading(new FastHashMap(ITERATIONS_FOR_QUICK));
    // TimeMeasure.end("executeWithIntegerAndMapAndMultiThreading with FastHashMap");
    //
    // TimeMeasure.begin("executeWithIntegerAndMapAndMultiThreading with TreeMap");
    // executorWithout.executeWithIntegerAndMapAndMultiThreading(new TreeMap());
    // TimeMeasure.end("executeWithIntegerAndMapAndMultiThreading with TreeMap");
    //
    // System.out.println("executeWithIntegerAndFastHashMap");
    // executorWithout.executeWithIntegerAndFastHashMap();
    //
    // System.out.println("executeWithIntegerAndHashMap");
    // executorWithout.executeWithIntegerAndHashMap();
    //
    // System.out.println("executeWithIntegerAndHashedMap");
    // executorWithout.executeWithIntegerAndHashedMap();
    // }
    // TimeMeasure.end("testWithIntegerKeys LoadReadExecutorWithoutMultiKey");

    TimeMeasure.begin("testWithIntegerKeys LoadReadExecutorWithEqualsHashCode"); //$NON-NLS-1$
    LoadReadExecutorWithEqualsHashCode executorEqualsHashCode = new LoadReadExecutorWithEqualsHashCode(
            ITERATIONS_FOR_QUICK);

    {
        for (int i = 0; i < 5; i++) {
            System.out.println("executeWithIntegerAndHashMap " + i); //$NON-NLS-1$
            executorEqualsHashCode.executeWithIntegerAndHashMap();
        }

    }
    TimeMeasure.end("testWithIntegerKeys LoadReadExecutorWithEqualsHashCode"); //$NON-NLS-1$

    System.gc();

    TimeMeasure.begin("testWithIntegerKeys LoadReadExecutorWithEqualsHashCode TreeMap"); //$NON-NLS-1$
    LoadReadExecutorWithEqualsHashCodeTreeMap executorEqualsHashCodeTreeMap = new LoadReadExecutorWithEqualsHashCodeTreeMap(
            ITERATIONS_FOR_QUICK);

    {
        for (int i = 0; i < 5; i++) {
            System.out.println("executeWithIntegerAndTreeMap  " + i); //$NON-NLS-1$
            executorEqualsHashCodeTreeMap.executeWithIntegerAndTreeMap();
        }

    }
    TimeMeasure.end("testWithIntegerKeys LoadReadExecutorWithEqualsHashCode TreeMap"); //$NON-NLS-1$

    System.gc();

    TimeMeasure.begin("testWithIntegerKeys executeWithMultiKey"); //$NON-NLS-1$
    LoadReadExecutorWithMultiKey executor = new LoadReadExecutorWithMultiKey(ITERATIONS_FOR_QUICK) {

        @Override
        protected Object[] getKeysFromRow(RowStruct row) {
            return new Object[] { row.integerKey };
        }

        @Override
        protected Object[] getKeysFromIndex(int i) {
            return new Object[] { integers.get(i), };
        }

    };
    executeWithMultiKey(executor);

    TimeMeasure.end("testWithIntegerKeys executeWithMultiKey"); //$NON-NLS-1$

}

From source file:knop.psfj.BeadAveragerSubPixel.java

@Override
public ImagePlus averageBead(ArrayList<BeadFrame> list) {

    ImagePlus result = null;//from w  w w  .  j a  v  a2 s . c  o m
    int extensionFactor = 10;
    int addedPixel = 3;
    PerfectCropper cropperX = null;
    PerfectCropper cropperY = null;
    PerfectCropper cropperZ = null;
    setTotalBeads(list.size());

    list = filter(list);

    int idealRange = (2 * addedPixel * extensionFactor);

    int fovWidth = list.get(0).getSource().getImageWidth();
    int fovHeight = list.get(0).getSource().getImageHeight();

    for (BeadFrame frame : list) {
        ExtendedBeadFrame extendedFrame = new ExtendedBeadFrame(frame, extensionFactor, addedPixel);

        int x = extendedFrame.boundaries.x;
        int y = extendedFrame.boundaries.y;
        int x2 = x + extendedFrame.boundaries.width;
        int y2 = y + extendedFrame.boundaries.height;

        // if the extended frame is out of the field of view, it,s not
        // taken into account
        if (x < 0 || y < 0 || x2 > fovWidth || y2 > fovHeight) {
            incrementFilteredOutBeadCount();
            continue;
        }
        extendedFrameList.add(extendedFrame);

        if (cropperX == null) {
            cropperX = new PerfectCropper(extendedFrame.getExtendedWidth(),
                    extendedFrame.getExtendedWidth() - idealRange);
            cropperY = new PerfectCropper(extendedFrame.getExtendedHeight(),
                    extendedFrame.getExtendedHeight() - idealRange);
            cropperZ = new PerfectCropper(extendedFrame.getExtendedDepth(), -1);
        }

        cropperX.addCenter(extendedFrame.getCentroidXAsInt());
        cropperY.addCenter(extendedFrame.getCentroidYAsInt());
        cropperZ.addCenter(extendedFrame.getCentroidZAsInt());

    }

    cropperX.calculateCommonRange();
    cropperY.calculateCommonRange();
    cropperZ.calculateCommonRange();

    ArrayList<ImageStack> centeredStacks = new ArrayList<ImageStack>();

    ImageStack averageStack = null;
    updateProgress(1, extendedFrameList.size());
    int p = 1;
    int max = extendedFrameList.size();
    // for each extended frame
    for (ExtendedBeadFrame extFrame : extendedFrameList) {

        // we get the extended frame
        ImageStack croppedStack = extFrame.getExtendedStack();

        // we calculate the boundaries of the ROI using the PerfectCropper
        // object
        // (it centers the center around the centroid).
        int x = cropperX.getBoundaryLeft(extFrame.getCentroidXAsInt());
        int w = cropperX.getBoundaryRight(extFrame.getCentroidXAsInt()) - x;

        int y = cropperY.getBoundaryLeft(extFrame.getCentroidYAsInt());
        int h = cropperY.getBoundaryRight(extFrame.getCentroidYAsInt()) - y;

        // StackProcessor processor = new StackProcessor(croppedStack);
        // the stack is cropped in X and Y
        croppedStack = ImageProcessorUtils.crop(croppedStack, new Rectangle(x, y, w, h));

        System.out.println(String.format("Cropped zone : (%d,%d) : %d x %d, max : %d\nfrom %d to %d", x, y, w,
                h, extFrame.getExtendedWidth(), cropperZ.getBoundaryLeft(extFrame.getCentroidZAsInt()),
                cropperZ.getBoundaryRight(extFrame.getCentroidZAsInt())));
        System.out.println(String.format("Effective Cropped zone : (%d,%d) : %d x %d,\nfrom %d to %d", x, y,
                croppedStack.getWidth(), croppedStack.getHeight(),
                cropperZ.getBoundaryLeft(extFrame.getCentroidZAsInt()),
                cropperZ.getBoundaryRight(extFrame.getCentroidZAsInt())));

        // then the stack is cropped in Z
        int originalStackSize = croppedStack.getSize();
        for (int i = cropperZ.getBoundaryRight(extFrame.getCentroidZAsInt()); i != originalStackSize; i++) {
            croppedStack.deleteLastSlice();
        }

        for (int i = 0; i != cropperZ.getBoundaryLeft(extFrame.getCentroidZAsInt()); i++) {
            croppedStack.deleteSlice(1);
        }
        System.out.println("stack size : " + croppedStack.getSize());
        // then the cropped stack is added to the future average stack
        if (averageStack == null) {
            averageStack = new ImageStack(croppedStack.getWidth(), croppedStack.getHeight());
            for (int i = 0; i != croppedStack.getSize(); i++) {
                averageStack.addSlice(croppedStack.getProcessor(i + 1).convertToFloat());
            }

        } else {
            addStack(croppedStack, averageStack);
        }
        updateProgress(p++, max + 10);
        if (p % 8 == 0)
            System.gc();

        // centeredStacks.add(croppedStack);

    }
    updateProgress(max + 2, max + 10);
    System.out.println("averaging endend. dviding by " + extendedFrameList.size());
    // the average stack is divided by the number of used stack
    for (int i = 0; i != averageStack.getSize(); i++) {
        averageStack.getProcessor(i + 1).multiply(1.0 / extendedFrameList.size());
    }

    System.out.println("stacling stack x y and z");
    // ImageStack averageStack = averageStacks(centeredStacks);
    ImagePlus averageStackImagePlus = new ImagePlus("Averaged Bead", averageStack);
    Scale scaler = new Scale();
    Image wrapper = Image.wrap(averageStackImagePlus);

    updateProgress(max + 5, max + 10);
    wrapper = scaler.run(wrapper, 1.0 / extensionFactor, 1.0 / extensionFactor, 1.0 / extensionFactor, 1.0, 1.0,
            Scale.LINEAR);
    updateProgress(max + 9, max + 10);
    System.gc();
    System.out.println(" the end");
    System.out.println(wrapper.imageplus());

    updateProgress(0, 7);
    return wrapper.imageplus();
}

From source file:com.edduarte.protbox.core.registry.PbxFile.java

/**
 * Suggests Java Garbage Collector to stop storing this file's data.
 */
void clearSnapshots() {
    snapshotStack.clear();
    snapshotStack = null;
    System.gc();
}

From source file:org.alfresco.util.transaction.SpringAwareUserTransactionTest.java

/**
 * Test for leaked transactions (no guarantee it will succeed due to reliance
 * on garbage collector), so disabled by default.
 * //  w ww.  j  av  a  2s.  co  m
 * Also, if it succeeds, transaction call stack tracing will be enabled
 * potentially hitting the performance of all subsequent tests.
 * 
 * @throws Exception
 */
public void xtestLeakedTransactionLogging() throws Exception {
    assertFalse(SpringAwareUserTransaction.isCallStackTraced());

    TrxThread t1 = new TrxThread();
    t1.start();
    System.gc();
    Thread.sleep(1000);

    TrxThread t2 = new TrxThread();
    t2.start();
    System.gc();
    Thread.sleep(1000);

    assertTrue(SpringAwareUserTransaction.isCallStackTraced());

    TrxThread t3 = new TrxThread();
    t3.start();
    System.gc();
    Thread.sleep(3000);
    System.gc();
    Thread.sleep(3000);
}

From source file:com.swg.parse.docx.OpenFolderAction.java

@Override
public void actionPerformed(ActionEvent e) {

    JFileChooser fc = new JFileChooser();
    fc.setCurrentDirectory(new File("C:/"));
    fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    if (selectedFile != null) {
        fc.setSelectedFile(selectedFile);
    }//www  .  j  a  v  a  2 s  .  c  o  m

    int returnVal = fc.showDialog(WindowManager.getDefault().getMainWindow(), "Extract Data");

    JFrame jf = new JFrame("Progress Bar");
    Container Jcontent = jf.getContentPane();
    JProgressBar progressBar = new JProgressBar();
    progressBar.setValue(0);
    progressBar.setStringPainted(true);
    Jcontent.add(progressBar, BorderLayout.NORTH);
    jf.setSize(300, 60);
    jf.setVisible(true);

    //we needed a new thread for a functional progress bar on the JFrame
    new Thread(new Runnable() {
        public void run() {

            if (returnVal == JFileChooser.APPROVE_OPTION) {

                File file = fc.getSelectedFile();
                selectedFile = file;

                FileFilter fileFilter = new WildcardFileFilter("*.docx");
                File[] files = selectedFile.listFiles(fileFilter);
                double cnt = 0, cnt2 = 0; //number of how many .docx is in the folder
                for (File f : files) {
                    if (!f.getAbsolutePath().contains("~"))
                        cnt2++;
                }

                for (File f : files) {
                    cnt++;
                    pathToTxtFile = f.getAbsolutePath().replace(".docx", ".txt");
                    TxtFile = new File(pathToTxtFile);

                    //----------------------------------------------------
                    String zipFilePath = "C:\\Users\\fja2\\Desktop\\junk\\Test\\test.zip";
                    String destDirectory = "C:\\Users\\fja2\\Desktop\\junk\\Test " + cnt;
                    UnzipUtility unzipper = new UnzipUtility();
                    try {
                        File zip = new File(zipFilePath);
                        File directory = new File(destDirectory);
                        FileUtils.copyFile(f, zip);
                        unzipper.UnzipUtility(zip, directory);

                        zip.delete();

                        String mediaPath = destDirectory + "/word/media/";
                        File mediaDir = new File(mediaPath);

                        for (File fil : mediaDir.listFiles()) {
                            FileUtils.copyFile(fil, new File("C:\\Users\\PXT1\\Desktop\\test\\Pictures\\"
                                    + f.getName() + "\\" + fil.getName()));
                        }

                        FileUtils.deleteDirectory(directory);

                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
                    //----------------------------------------------------

                    //if the txt file doesn't exist, it tries to convert whatever 
                    //can be the txt into the actual txt.
                    if (!TxtFile.exists()) {
                        pathToTxtFile = f.getAbsolutePath().replace(".docx", "");
                        TxtFile = new File(pathToTxtFile);
                        pathToTxtFile += ".txt";
                        TxtFile.renameTo(new File(pathToTxtFile));
                        TxtFile = new File(pathToTxtFile);
                    }

                    String content = "";
                    String POIContent = "";

                    try {
                        content = readTxtFile();
                        version = DetermineVersion(content);
                        NewExtract ext = new NewExtract();
                        ext.extract(content, f.getAbsolutePath(), version, (int) cnt);

                    } catch (FileNotFoundException ex) {
                        Exceptions.printStackTrace(ex);
                    } catch (IOException ex) {
                        Exceptions.printStackTrace(ex);
                    } catch (ParseException ex) {
                        Exceptions.printStackTrace(ex);
                    }

                    double tempProg = (cnt / cnt2) * 100;
                    progressBar.setValue((int) tempProg);
                    System.gc();
                }

            } else {
                //do nothing
            }
        }
    }).start();

    System.gc();

}

From source file:com.tesora.dve.standalone.PETest.java

@AfterClass
public static void teardownPETest() throws Throwable {
    delay("tearing down the PE", "afterClass.delay", 100L);

    if (stateUndoer != null)
        stateUndoer.undo();//  w  w  w  .ja v  a  2 s.c om

    if (catalogDAO != null) {
        catalogDAO.close();
        catalogDAO = null;
    }

    List<Throwable> finalThrows = new ArrayList<Throwable>();

    try {
        SSConnectionProxy.checkForLeaks();
    } catch (Throwable e) {
        // Don't throw the exception now - since we want to continue doing
        // cleanup
        finalThrows.add(e);
    }

    if (bootHost != null) {
        try {
            checkForLeakedLocks(Singletons.lookup(LockManager.class));
        } catch (Throwable e) {
            finalThrows.add(e);
        }

        // if (!bootHost.getWorkerManager().allWorkersReturned())
        // finalThrows.add(new Exception("Not all workers returned"));

        BootstrapHost.stopServices();

        bootHost = null;
    }

    System.gc();//request garbage collection run, to try and force unreferenced buffers to get collected.
    final long numOfLeaksDetected = leakCount.clearEmittedLeakCount();
    if (numOfLeaksDetected > NETTY_LEAK_COUNT_BASE) {
        finalThrows.add(new Exception("Total of '" + numOfLeaksDetected
                + "' Netty ByteBuf leaks detected!  Inspect slf4j output for netty leak errors, and consider re-running tests with -Dio.netty.leakDetectionLevel=PARANOID"));
    }

    if (finalThrows.size() > 0) {
        if (logger.isDebugEnabled()) {
            for (Throwable th : finalThrows) {
                logger.debug(th);
            }
        }
        throw finalThrows.get(0);
    }
}

From source file:com.google.gdt.eclipse.designer.ie.jsni.ModuleSpaceIE6.java

@Override
public void dispose() {
    for (NativeFunctionInfo function : m_nativeFunctions.values()) {
        function.dispose();//from  w  w w . j  av  a 2s.  co m
    }
    // Dispose everything else.
    if (window != null) {
        window.dispose();
    }
    super.dispose();
    IDispatchProxy.clearIDispatchProxyRefs(getIsolatedClassLoader());
    for (int i = 0; i < 2; i++) {
        if (!GWTEnvironmentUtils.DEVELOPERS_HOST) {
            System.gc();
        }
        System.runFinalization();
        JsValue.mainThreadCleanup();
    }
}

From source file:com.ln.gui.Main.java

@SuppressWarnings("unchecked")
public Main() {//from   w w  w.  ja v  a  2 s .  c om
    System.gc();
    setIconImage(Toolkit.getDefaultToolkit().getImage(Configuration.mydir + "\\resources\\icons\\ln6464.png"));
    DateFormat dd = new SimpleDateFormat("dd");
    DateFormat dh = new SimpleDateFormat("HH");
    DateFormat dm = new SimpleDateFormat("mm");
    Date day = new Date();
    Date hour = new Date();
    Date minute = new Date();
    dayd = Integer.parseInt(dd.format(day));
    hourh = Integer.parseInt(dh.format(hour));
    minutem = Integer.parseInt(dm.format(minute));
    setTitle("Liquid Notify Revision 2");
    Description.setBackground(Color.WHITE);
    Description.setContentType("text/html");
    Description.setEditable(false);
    Getcalendar.Main();
    HyperlinkListener hyperlinkListener = new ActivatedHyperlinkListener(f, Description);
    Description.addHyperlinkListener(hyperlinkListener);
    //Add components
    setContentPane(contentPane);
    setJMenuBar(menuBar);
    contentPane.setLayout(
            new MigLayout("", "[220px:230.00:220,grow][209.00px:n:5000,grow]", "[22px][][199.00,grow][grow]"));
    eventsbtn.setToolTipText("Displays events currently set to notify");
    eventsbtn.setMinimumSize(new Dimension(220, 23));
    eventsbtn.setMaximumSize(new Dimension(220, 23));
    contentPane.add(eventsbtn, "cell 0 0");
    NewsArea.setBackground(Color.WHITE);
    NewsArea.setBorder(new BevelBorder(BevelBorder.LOWERED, Color.LIGHT_GRAY, Color.LIGHT_GRAY, Color.DARK_GRAY,
            Color.DARK_GRAY));
    NewsArea.setMinimumSize(new Dimension(20, 22));
    NewsArea.setMaximumSize(new Dimension(10000, 22));
    contentPane.add(NewsArea, "cell 1 0,growx,aligny top");
    menuBar.add(File);
    JMenuItem Settings = new JMenuItem("Settings");
    Settings.setIcon(new ImageIcon(Configuration.mydir + "\\resources\\icons\\settings.png"));
    Settings.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            Settings setup = new Settings();
            setup.setVisible(true);
            setup.setLocationRelativeTo(rootPane);
        }
    });
    File.add(Settings);
    File.add(mntmNewMenuItem);
    Tray.setIcon(new ImageIcon(Configuration.mydir + "\\resources\\icons\\ln1616.png"));
    File.add(Tray);
    Exit.setIcon(new ImageIcon(Configuration.mydir + "\\resources\\icons\\exit.png"));
    File.add(Exit);

    menuBar.add(mnNewMenu);

    Update.setIcon(new ImageIcon(Configuration.mydir + "\\resources\\icons\\update.png"));
    Update.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                URL localURL = new URL("http://jiiks.net23.net/tlnotify/online.html");
                URLConnection localURLConnection = localURL.openConnection();
                BufferedReader localBufferedReader = new BufferedReader(
                        new InputStreamReader(localURLConnection.getInputStream()));
                String str = localBufferedReader.readLine();
                if (!str.contains("YES")) {
                    String st2221 = "Updates server appears to be offline";
                    JOptionPane pane1 = new JOptionPane(st2221, JOptionPane.WARNING_MESSAGE,
                            JOptionPane.DEFAULT_OPTION);
                    JDialog dialog1 = pane1.createDialog("Update");
                    dialog1.setLocationRelativeTo(null);
                    dialog1.setVisible(true);
                    dialog1.setAlwaysOnTop(true);
                } else if (str.contains("YES")) {
                    URL localURL2 = new URL("http://jiiks.net23.net/tlnotify/latestversion.html");
                    URLConnection localURLConnection1 = localURL2.openConnection();
                    BufferedReader localBufferedReader2 = new BufferedReader(
                            new InputStreamReader(localURLConnection1.getInputStream()));
                    String str2 = localBufferedReader2.readLine();
                    Updatechecker.latestver = str2;
                    if (Integer.parseInt(str2) <= Configuration.version) {
                        String st2221 = "No updates available =(";
                        JOptionPane pane1 = new JOptionPane(st2221, JOptionPane.WARNING_MESSAGE,
                                JOptionPane.DEFAULT_OPTION);
                        JDialog dialog1 = pane1.createDialog("Update");
                        dialog1.setLocationRelativeTo(null);
                        dialog1.setVisible(true);
                        dialog1.setAlwaysOnTop(true);
                    } else if (Integer.parseInt(str2) > Configuration.version) {
                        String st2221 = "Updates available!";
                        JOptionPane pane1 = new JOptionPane(st2221, JOptionPane.WARNING_MESSAGE,
                                JOptionPane.DEFAULT_OPTION);
                        JDialog dialog1 = pane1.createDialog("Update");
                        dialog1.setLocationRelativeTo(null);
                        dialog1.setVisible(true);
                        dialog1.setAlwaysOnTop(true);

                        Updatechecker upd = new Updatechecker();
                        upd.setVisible(true);
                        upd.setLocationRelativeTo(rootPane);
                        upd.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
                    }
                }
            } catch (MalformedURLException e1) {
                e1.printStackTrace();
            } catch (IOException e1) {
                e1.printStackTrace();
            }

        }

    });
    mnNewMenu.add(Update);
    JMenuItem About = new JMenuItem("About");
    About.setIcon(new ImageIcon(Configuration.mydir + "\\resources\\icons\\about.png"));
    About.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            About a = new About();
            a.setVisible(true);
            a.setLocationRelativeTo(rootPane);
            a.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        }
    });
    mnNewMenu.add(About);
    JMenuItem Github = new JMenuItem("Github");
    Github.setIcon(new ImageIcon(Configuration.mydir + "\\resources\\icons\\github.png"));
    Github.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String url = "https://github.com/Jiiks/Liquid-Notify-Rev2";
            try {
                java.awt.Desktop.getDesktop().browse(java.net.URI.create(url));
            } catch (IOException e1) {
                e1.printStackTrace();
            }
        }
    });
    mnNewMenu.add(Github);
    JMenuItem Thread = new JMenuItem("Thread");
    Thread.setIcon(new ImageIcon(Configuration.mydir + "\\resources\\icons\\liquid.png"));
    Thread.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String url = "http://www.teamliquid.net/forum/viewmessage.php?topic_id=318184";
            try {
                java.awt.Desktop.getDesktop().browse(java.net.URI.create(url));
            } catch (IOException e1) {
                e1.printStackTrace();
            }
        }
    });
    mnNewMenu.add(Thread);
    Refreshbtn.setToolTipText("Refreshes calendar, please don't spam ^_^");
    Refreshbtn.setPreferredSize(new Dimension(90, 20));
    Refreshbtn.setMinimumSize(new Dimension(100, 20));
    Refreshbtn.setMaximumSize(new Dimension(100, 20));
    contentPane.add(Refreshbtn, "flowx,cell 0 1,alignx left");
    //Components to secondary panel   
    Titlebox = new JComboBox();
    contentPane.add(Titlebox, "cell 1 1,growx,aligny top");
    Titlebox.setMinimumSize(new Dimension(20, 20));
    Titlebox.setMaximumSize(new Dimension(10000, 20));
    //Set other
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 686, 342);
    contentPane.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
    NewsArea.setEnabled(false);
    NewsArea.setEditable(false);
    NewsArea.setText("News: " + News);
    contentPane.add(panel, "cell 0 2,grow");
    panel.setLayout(null);
    final JCalendar calendar = new JCalendar();
    calendar.getMonthChooser().setPreferredSize(new Dimension(120, 20));
    calendar.getMonthChooser().setMinimumSize(new Dimension(120, 24));
    calendar.getYearChooser().setLocation(new Point(20, 0));
    calendar.getYearChooser().setMaximum(100);
    calendar.getYearChooser().setMaximumSize(new Dimension(100, 2147483647));
    calendar.getYearChooser().setMinimumSize(new Dimension(50, 20));
    calendar.getYearChooser().setPreferredSize(new Dimension(50, 20));
    calendar.getYearChooser().getSpinner().setPreferredSize(new Dimension(100, 20));
    calendar.getYearChooser().getSpinner().setMinimumSize(new Dimension(100, 20));
    calendar.getMonthChooser().getSpinner().setPreferredSize(new Dimension(119, 20));
    calendar.getMonthChooser().getSpinner().setMinimumSize(new Dimension(120, 24));
    calendar.getDayChooser().getDayPanel().setFont(new Font("Tahoma", Font.PLAIN, 11));
    calendar.setDecorationBordersVisible(true);
    calendar.setTodayButtonVisible(true);
    calendar.setBackground(Color.LIGHT_GRAY);
    calendar.setBounds(0, 0, 220, 199);
    calendar.getDate();
    calendar.setWeekOfYearVisible(false);
    calendar.setDecorationBackgroundVisible(false);
    calendar.setMaxDayCharacters(2);
    calendar.getDayChooser().setFont(new Font("Tahoma", Font.PLAIN, 10));
    panel.add(calendar);
    Descriptionscrollpane.setLocation(new Point(100, 100));
    Descriptionscrollpane.setMaximumSize(new Dimension(10000, 10000));
    Descriptionscrollpane.setMinimumSize(new Dimension(20, 200));
    Description.setLocation(new Point(100, 100));
    Description.setBorder(new BevelBorder(BevelBorder.LOWERED, Color.LIGHT_GRAY, Color.LIGHT_GRAY,
            Color.DARK_GRAY, Color.DARK_GRAY));
    Description.setMaximumSize(new Dimension(1000, 400));
    Description.setMinimumSize(new Dimension(400, 200));
    contentPane.add(Descriptionscrollpane, "cell 1 2 1 2,growx,aligny top");
    Descriptionscrollpane.setViewportView(Description);
    verticalStrut.setMinimumSize(new Dimension(12, 20));
    contentPane.add(verticalStrut, "cell 0 1");
    Notify.setToolTipText("Adds selected event to notify event list.");
    Notify.setHorizontalTextPosition(SwingConstants.CENTER);
    Notify.setPreferredSize(new Dimension(100, 20));
    Notify.setMinimumSize(new Dimension(100, 20));
    Notify.setMaximumSize(new Dimension(100, 20));
    contentPane.add(Notify, "cell 0 1,alignx right");
    calendar.getMonthChooser().addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            month = calendar.getMonthChooser().getMonth();
            Parser.parse();
        }
    });

    calendar.getDayChooser().addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            try {
                int h = calendar.getMonthChooser().getMonth();
                @SuppressWarnings("deprecation")
                int date = calendar.getDate().getDate();
                int month = calendar.getMonthChooser().getMonth() + 1;
                globmonth = calendar.getMonthChooser().getMonth();
                sdate = date;
                datestring = Integer.toString(sdate);
                monthstring = Integer.toString(month);
                String[] Hours = Betaparser.Hours;
                String[] Titles = Betaparser.STitle;
                String[] Full = new String[Hours.length];
                String[] Minutes = Betaparser.Minutes;
                String[] Des = Betaparser.Description;
                String[] Des2 = new String[Betaparser.Description.length];
                String Seconds = "00";
                String gg;
                int[] IntHours = new int[Hours.length];
                int[] IntMins = new int[Hours.length];
                int Events = 0;
                monthday = monthstring + "|" + datestring + "|";
                Titlebox.removeAllItems();
                for (int a = 0; a != Hours.length; a++) {
                    IntHours[a] = Integer.parseInt(Hours[a]);
                    IntMins[a] = Integer.parseInt(Minutes[a]);
                }
                for (int i1 = 0; i1 != Hours.length; i1++) {
                    if (Betaparser.Events[i1].startsWith(monthday)) {
                        Full[i1] = String.format("%02d:%02d", IntHours[i1], IntMins[i1]) + " | " + Titles[i1];
                        Titlebox.addItem(Full[i1]);
                    }
                }
            } catch (Exception e1) {
                //Catching mainly due to boot property change            
            }
        }
    });
    Image image = Toolkit.getDefaultToolkit().getImage(Configuration.mydir + "\\resources\\icons\\ln1616.png");
    final SystemTray tray = SystemTray.getSystemTray();
    ActionListener listener = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setVisible(true);
        }
    };
    PopupMenu popup = new PopupMenu();
    MenuItem defaultItem = new MenuItem();
    defaultItem.addActionListener(listener);
    TrayIcon trayIcon = null;
    trayIcon = new TrayIcon(image, "LiquidNotify Revision 2", popup);

    trayIcon.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent arg0) {
            setVisible(true);
        }
    });//
    try {
        tray.add(trayIcon);
    } catch (AWTException e) {
        System.err.println(e);
    }
    if (trayIcon != null) {
        trayIcon.setImage(image);
    }

    Tray.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setVisible(false);
        }
    });

    Titlebox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            Descparser.parsedesc();
        }
    });

    Refreshbtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            Getcalendar.Main();
            Descparser.parsedesc();
        }
    });

    Notify.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            NOTIFY = Descparser.TTT;
            NOTIFYD = Descparser.DDD;
            NOTIFYH = Descparser.HHH;
            NOTIFYM = Descparser.MMM;
            int i = events;
            NOA[i] = NOTIFY;
            NOD[i] = NOTIFYD;
            NOH[i] = NOTIFYH;
            NOM[i] = NOTIFYM;
            Eventlist[i] = "Starts in: " + Integer.toString(NOD[i]) + " Days " + Integer.toString(NOH[i])
                    + " Hours " + Integer.toString(NOM[i]) + " Minutes " + " | " + NOA[i];
            events = events + 1;
            Notifylist si = new Notifylist();
            si.setVisible(false);
            si.setBounds(1, 1, 1, 1);
            si.dispose();
            if (thread.getState().name().equals("PENDING")) {
                thread.execute();
            }
        }
    });
    eventsbtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            Notifylist list = new Notifylist();
            if (played == 1) {
                asd.close();
                played = 0;
            }
            list.setVisible(true);
            list.setLocationRelativeTo(rootPane);
            list.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        }
    });

    mntmNewMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (thread.getState().name().equals("PENDING")) {
                thread.execute();
            }
            Userstreams us = new Userstreams();
            us.setVisible(true);
            us.setLocationRelativeTo(rootPane);
        }
    });

    Exit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            //Absolute exit
            JOptionPane.showMessageDialog(rootPane, "Bye bye :(", "Exit", JOptionPane.INFORMATION_MESSAGE);
            Runtime ln = Runtime.getRuntime();
            ln.gc();
            final Frame[] allf = Frame.getFrames();
            final Window[] allw = Window.getWindows();
            for (final Window allwindows : allw) {
                allwindows.dispose();
            }
            for (final Frame allframes : allf) {
                allframes.dispose();
                System.exit(0);
            }
        }
    });
}