title: Runnable Jar Files slow compared to Eclipse
body: <p>I have found only a small number of Threats about this Problem, but nothing seems to solve it.</p>
  
  <p>My code runs in Eclipse under 10 seconds. If I extract this Project into a runnable jar file it takes over 5-10 minutes.</p>
  
  <p>What I do: I read two .txt files, combine them, sort them, separate them and save them.
  This is my code:</p>
  
  <pre><code>package de.***.timcooparser;
  
  import java.io.BufferedReader;
  import java.io.BufferedWriter;
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.FileNotFoundException;
  import java.io.FileWriter;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.InputStreamReader;
  import java.util.ArrayList;
  import java.util.List;
  
  import javax.swing.JOptionPane;
  
  import org.joda.time.DateTime;
  import org.joda.time.DateTimeZone;
  
  import com.google.code.externalsorting.ExternalSort;
  
  
  public class TimCooParser {
  
    private static List&lt;String&gt; listCoordinates = new ArrayList&lt;String&gt;();
    private static List&lt;String&gt; listTimestamps = new ArrayList&lt;String&gt;();
    private static List&lt;String&gt; listTimeCoord = new ArrayList&lt;String&gt;();
  
  
    public static void main(String[ ] args) throws IOException {
  
      //Start Time
      long d1 = System.currentTimeMillis();
  
      //Create Path
        String path = new File("").getAbsolutePath();
  
      //Readfiles
      File fileTimeCoord = new File (path+"\\TimestampsCoordinates.txt");
      File fileTimeCoord2 = new File (path+"\\TimestampsCoordinates2.txt");
      File fileCoordinates = new File (path+"\\Coordinates.txt");
      File fileTimestamps = new File (path+"\\Timestamps.txt");
  
      try{
  
  
        if (fileTimeCoord.exists()){
          fileTimeCoord.delete();
        }
        fileCoordinates.createNewFile();
  
        //Read Coordinates an Timestamps and merge them
        InputStream is1 = new FileInputStream(fileTimestamps);
        InputStreamReader instrm1 = new InputStreamReader(is1);
        BufferedReader br1 = new BufferedReader(instrm1);
  
        InputStream is2 = new FileInputStream(fileCoordinates);
        InputStreamReader instrm2 = new InputStreamReader(is2);
        BufferedReader br2 = new BufferedReader(instrm2);
  
        String line = "", line2 = "";
        Integer i = 0;
        while ((line = br1.readLine()) != null){
          line2 = br2.readLine();
          String[] arrayTemp = line2.split(" ");
          listTimeCoord.add(line+","+arrayTemp[0] + "," + arrayTemp[1]);
          i++;
  
          if (i&gt;=500){
            i=0;
            saveFiles(fileTimeCoord);
          }
        }
        br1.close();
        br2.close();
  
        //Sort File and delete old file
        ExternalSort.sort(fileTimeCoord, fileTimeCoord2);
        fileTimeCoord.delete();
  
        //Delete old files
        if (fileCoordinates.exists()){
          fileCoordinates.delete();
        }
        fileCoordinates.createNewFile();
  
        if (fileTimestamps.exists()){
          fileTimestamps.delete();
        }
        fileTimestamps.createNewFile();
  
  
        //Read TimeCoord and override Timestamps and Coordinates
        InputStream is3 = new FileInputStream(fileTimeCoord2);
        InputStreamReader instrm3 = new InputStreamReader(is3);
        BufferedReader br3 = new BufferedReader(instrm3);
  
        line = "";
        listCoordinates.clear();
        listTimestamps.clear();
        Integer ct = 0;
        while ((line = br3.readLine()) != null){
          String[] arrayTemp = line.split(",");
          listTimestamps.add(arrayTemp[0]);
          listCoordinates.add(arrayTemp[1] + " " + arrayTemp[2]);
          ct++;
  
          if (ct &gt;= 500){
            saveFiles(fileTimestamps, fileCoordinates);
          }
        }
        br3.close();
  
        // Delete old Files
        fileTimeCoord2.delete();
  
        //get end Time
        long d2 = System.currentTimeMillis();
  
        //Get diff time
        long diff = d2 - d1;
        String diffTime = "Finished in " + ((diff / (60 * 60 * 1000)) % 24) + " hours " + ((diff / (60 * 1000)) % 60) + " minutes and "
            + ((diff / 1000) % 60) + " seconds";
  
        JOptionPane.showMessageDialog(null,  "Parser finished in: \n" + diffTime,"TimesCoord Parser", JOptionPane.INFORMATION_MESSAGE);
      }
      catch (FileNotFoundException e) {
        e.printStackTrace();
        JOptionPane.showMessageDialog(null,"Parser Error:\n" + e,"TimesCoord Parser", JOptionPane.CANCEL_OPTION);
      } 
      catch (IOException e) {
        e.printStackTrace();
        JOptionPane.showMessageDialog(null,"Parser Error:\n" + e,"TimesCoord Parser", JOptionPane.CANCEL_OPTION);
      }
    }
  
    private static void saveFiles(File fileTimestamps, File fileCoordinates) throws IOException {
  
      List&lt;String&gt; listCoordinates2 = new ArrayList&lt;String&gt;();
      List&lt;String&gt; listTimestamps2 = new ArrayList&lt;String&gt;();
  
      listCoordinates2.addAll(listCoordinates);
      listCoordinates.clear();
  
      listTimestamps2.addAll(listTimestamps);
      listTimestamps.clear();
  
      //Write to File
      BufferedWriter bw1 = new BufferedWriter(    new FileWriter(fileTimestamps, true));
  
      for (String string : listTimestamps2) {
        bw1.append(string + "\n");
      }
      bw1.close();
  
      //Write to File
      BufferedWriter bw2 = new BufferedWriter(    new FileWriter(fileCoordinates, true));
  
      for (String string : listCoordinates2) {
        bw2.append(string + "\n");
      }
      bw2.close();
  
  
    }
  
    private static void saveFiles(File fileTimeCoord) throws IOException {
  
      List&lt;String&gt; listTimeCoord2 = new ArrayList&lt;String&gt;();
  
      listTimeCoord2.addAll(listTimeCoord);
      listTimeCoord.clear();
  
      //Write to File
      BufferedWriter bw1 = new BufferedWriter(    new FileWriter(fileTimeCoord, true));
  
      for (String string : listTimeCoord2) {
        bw1.append(string + "\n");
      }
      bw1.close();        
    }
  
  
  
    public static String TimestampToDate(long stringDate)
    {
      DateTimeZone zone = DateTimeZone.forID("Europe/Berlin");
      DateTimeZone.setDefault(zone);
      DateTime actual = new DateTime(stringDate);
      String dateString = actual.toString("yyyy-MM-dd'T'HH:mm:ssZZ");
      return dateString;
  
    }
  }
  </code></pre>
  
  <p>The eclipse and my PC do use the same JVM:</p>
  
  <pre class="lang-none prettyprint-override"><code>java version "1.8.0_20"     
  Java(TM) SE Runtime Environment (build 1.8.0_20-b26)     
  Java HotSpot(TM) Client VM (build 25.20-b23, mixed mode, sharing)
  </code></pre>
  
  <p>And here is my eclipse.ini:</p>
  
  <pre class="lang-none prettyprint-override"><code>-startup
  plugins/org.eclipse.equinox.launcher_1.3.0.v20140415-2008.jar
  --launcher.library
  plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.200.v20140603-1326
  -product
  org.eclipse.epp.package.java.product
  --launcher.defaultAction
  openFile
  --launcher.XXMaxPermSize
  256M
  -showsplash
  org.eclipse.platform
  --launcher.XXMaxPermSize
  256m
  --launcher.defaultAction
  openFile
  --launcher.appendVmargs
  -vmargs
  -Dosgi.requiredJavaVersion=1.6
  -Xms512m
  -Xmx1024m
  </code></pre>
  
  <p>What can I do to solve this Problem?</p>
  
  <p>PS: It is independent of the "externalsortinginjava.." library.</p>