0

I first tried to run my jar file by java -jar test2.jar and got the following error "Failure to load main class Manifest attribute from test2.jar"

after googling stack overflow i came up with a solution saying i needed a manefest file with the nsme of the starting class.
I tried the following

jar cfm app.jar man.txt Now nothing happens, after I type the line the curser just goes to the next line man file looks like Main-Class: cStart

my cstart looks like

public class cStart {
    public static void main (String[] args) {
        Scanner scanner = new Scanner(System.in);

         cRiunTest test;
         test=new cRiunTest();
         test.run();

        if (true)
            return;
    }
}
Ted pottel
  • 6,869
  • 21
  • 75
  • 134

1 Answers1

0

Jar command is to manipulate jar (java archive) files. To run a jar you should use the command java -jar program.jar

Rafael Saraiva
  • 908
  • 2
  • 11
  • 23
  • I did that and got the following error"Failed to load Main-Class manifest attribute from test2.jar" – Ted pottel Oct 29 '14 at 23:03
  • I work with NetBeans and it automatically creates the manifest for the project. I think any IDE should do that. Try browsing any of the following link to see if something comes up: http://stackoverflow.com/questions/9689793/cant-execute-jar-file-no-main-manifest-attribute – Rafael Saraiva Oct 30 '14 at 14:01
  • Or http://stackoverflow.com/questions/5507184/creating-a-jar-file-get-could-not-find-main-class-even-with-manifest-txt-wi – Rafael Saraiva Oct 30 '14 at 14:02
  • And to clarify. A manifest.mf file created by Netbeans should have something like: Manifest-Version: 1.0 X-COMMENT: Main-Class will be added automatically by build – Rafael Saraiva Oct 30 '14 at 14:03