0

Possible Duplicate:
Causes of 'java.lang.NoSuchMethodError: main Exception in thread “main”'

I am trying to write a byte array in a text file. It is giving me error:

java.lang.NoSuchMethodError: main Exception in thread "main"

The code i am using is as under

    import java.io.BufferedWriter;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.io.Writer;
    public class writefile {
//it works well
    public static void main()throws IOException{
        Writer output = null;
      byte[] a= {1,2,3,4,5,6};

       try {
      String text = "abcd...\n";
      String str3 = text.concat("the end");
      String NL = System.getProperty("line.separator");
      str3 = str3.concat(NL);
      str3= str3.concat("next line");
      for ( int i=0; i < a.length; i++){
          str3 = str3.concat(NL);
          str3= str3.concat(" " +a[i]);
      }
      File file = new File("write.txt");
      output = new BufferedWriter(new FileWriter(file));
      output.write(str3);
      System.out.println("Your file has been written");
      } catch (FileNotFoundException e) {
          e.printStackTrace();
          } catch (IOException e) {
          e.printStackTrace();
          } finally {
              try {
                  if (output != null) {
                      output.close();
                      }
                  } catch (IOException e) {
                      e.printStackTrace();
                      }
                  }
      }

}

Kindly help how can i resolve the problem.

Community
  • 1
  • 1
WBAN
  • 71
  • 1
  • 5

2 Answers2

0

The main method of a Java program must take an argument of type String[] representing the arguments (if any) passed to the program on launch.

Ben
  • 2,278
  • 2
  • 17
  • 26
0

the main signature must contain String[] argument

LeleDumbo
  • 9,012
  • 4
  • 21
  • 38