title: Java manifest file
body: <p>As a note, I am no Java Developer but I have limited knowledge from High School.<br>
  I was asked to make a simple program just to generate a report and then view it, et cetera (which worked).</p>
  
  <p>I am ecstatic that it works but unfortunately I cannot get the <code>.jar</code> file to run once I have made it executable I am presuming that it is due to the manifest file not calling exactly what is needed.</p>
  
  <p>I have looked online for help but cannot seem to grasp the concept.</p>
  
  <p>Main class:</p>
  
  <pre><code>package writeBatchFile;
  
  import java.awt.Desktop;
  import java.awt.Dimension;
  import java.awt.GridLayout;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import java.io.BufferedWriter;
  import java.io.File;
  import java.io.FileWriter;
  import java.io.IOException;
  
  import javax.swing.*;
  
  public class mainFile {
  
      public static void main(String[] args) {
  
          JFrame myFrame = new JFrame("youwillneverfigurethisout");
          myFrame.setLayout(new GridLayout(4, 4));
          myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  
          JButton oneDayReport = new JButton("Create Day Report");
          JButton weekReport = new JButton("Create Week Report");
          JButton monthReport = new JButton("Create Month Report"); 
          JButton runBatch = new JButton("Run Batch File");
          JButton viewReport = new JButton("Open Report");
          JButton exit = new JButton("Exit");
          oneDayReport.setPreferredSize(new Dimension(100, 100));
  
          JLabel label = new JLabel("Please Click On Create Batch ");
          JLabel blank = new JLabel("File and then Run Batch File");
  
          myFrame.add(label);
          myFrame.add(blank);
          myFrame.add(oneDayReport);
          myFrame.add(weekReport);
          myFrame.add(monthReport);
          myFrame.add(runBatch);
          myFrame.add(viewReport);
          myFrame.add(exit);
          myFrame.setVisible(true);
          myFrame.setTitle("Report Generator");
          myFrame.setSize(400, 200);
          myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  
          oneDayReport.addActionListener(new ActionListener() {
  
              public void actionPerformed(ActionEvent write) {
                  try {   
                      String input1 = JOptionPane.showInputDialog("Please Input the Date for the report (ie: 04/07/2014-04/07/2014)");
                      String input2 = input1;
                      String line1 = "@echo";
                      String line2 = "C:\\sarg\\sbin\\sarg –d " + input1 + "-" + input2;
                      String line3 = "pause";
  
                      File file = new File("generateReport.bat");
  
                      // if file doesnt exists, then create it
                      if (!file.exists()) {
                          file.createNewFile();
                      }
  
                      FileWriter fw = new FileWriter(file.getAbsoluteFile());
                      BufferedWriter bw = new BufferedWriter(fw);
                      bw.write(line1);
                      bw.write("\r\n \r\n" + line2);
                      bw.write("\r\n \r\n" + line3);
                      bw.close();
  
                      System.out.println("Done");
  
                  } catch(IOException c) {
                      c.printStackTrace();
                  }
              }
          });
  
          weekReport.addActionListener(new ActionListener() {
  
              public void actionPerformed(ActionEvent write) {
                  try {   
                      String input1 = JOptionPane.showInputDialog("Please a 'from' date for the report (ie: 04/07/2014)");
                      String input2 = JOptionPane.showInputDialog("Please input a 'to' date for the report (ie: 11/07/2014");
                      String line1 = "@echo";
                      String line2 = "C:\\sarg\\sbin\\sarg –d -w " + input1 + "-" + input2;
                      String line3 = "pause";
  
                      File file = new File("generateReport.bat");
  
                      // if file doesnt exists, then create it
                      if ( !file.exists())
                          file.createNewFile();
  
                      FileWriter fw = new FileWriter(file.getAbsoluteFile());
                      BufferedWriter bw = new BufferedWriter(fw);
                      bw.write(line1);
                      bw.write("\r\n \r\n" + line2);
                      bw.write("\r\n \r\n" + line3);
                      bw.close();
  
                      System.out.println("Done");
  
                  } catch (IOException c) {
                      c.printStackTrace();
                  }
              }
          });
  
          monthReport.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent write) {
                  try {   
                      String input1 = JOptionPane.showInputDialog("Please a 'from' date for the report (ie: 04/07/2014)");
                      String input2 = JOptionPane.showInputDialog("Please input a 'to' date for the report (ie: 24/07/2014");
                      String line1 = "@echo";
                      String line2 = "C:\\sarg\\sbin\\sarg –d -w -m" + input1 + "-" + input2;
                      String line3 = "pause";
  
                      File file = new File("generateReport.bat");
  
                      // if file doesnt exists, then create it
                      if ( !file.exists()) {
                          file.createNewFile();
                      }
  
                      FileWriter fw = new FileWriter(file.getAbsoluteFile());
                      BufferedWriter bw = new BufferedWriter(fw);
                      bw.write(line1);
                      bw.write("\r\n \r\n" + line2);
                      bw.write("\r\n \r\n" + line3);
                      bw.close();
  
                      System.out.println("Done");
  
                  } catch(IOException c) {
                      c.printStackTrace();
                  }
              }
          });
  
          runBatch.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent read) {
                  try {    
                      Process p = Runtime.getRuntime().exec("cmd /c start generateReport.bat");
                      p.waitFor();
  
                  } catch(IOException ex) {
                      // Validate the case the file can't be accessed (not enough permissions)
                  } catch(InterruptedException ex) {
                      // Validate the case the process is being stopped by some external situation     
                  }
              }
          });
  
          viewReport.addActionListener(new ActionListener() {
  
              public void actionPerformed(ActionEvent read) {
  
                  try {    
  
                   // using this in real life, you'd probably want to check that the desktop
                   // methods are supported using isDesktopSupported()...
  
                   String htmlFilePath = "test.html"; // path to your new file
                   File htmlFile = new File(htmlFilePath);
  
                   // open the default web browser for the HTML page
                   Desktop.getDesktop().browse(htmlFile.toURI());
  
                   // if a web browser is the default HTML handler, this might work too
                   Desktop.getDesktop().open(htmlFile);
  
                  } catch(IOException ex) {
                      // Validate the case the file can't be accesed (not enought permissions)
                  }
              }
          });
  
          exit.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent close) {
                  System.exit(0);
              }
          });
      }
  }
  </code></pre>
  
  <p>And my <strong>manifest.mf</strong> looks like such:</p>
  
  <pre><code>Manifest-Version: 1.0
  Class-Path: mainFile.class
  Main-Class: writeBatchFile.mainFile
  </code></pre>
  
  <p>As far as I am aware, It is due to the files I am importing such as <code>java.awt</code> and <code>java.io</code> but if <em>anyone</em> can write me a manifest file for this or tell me how to create it using either Eclipse or JCreator, I would <em>greatly</em> appreciate it.</p>