0

When trying to open my exported project (jar file) I get an error message

No main manifest attribute, in file.jar.

My project is basically a simple class extended by Applet, but the file won't open. My java is up to date and I've tried using the line in cmd

java -jar file.jar 

in order to open it, but it still doesn't work.

What is the reason that the main class isn't recognized?

Thanks for the help!

  • Applets are dead (and ran in a web browser). – Elliott Frisch Mar 25 '17 at 19:16
  • possible duplicate http://stackoverflow.com/questions/9689793/cant-execute-jar-file-no-main-manifest-attribute – Japu_D_Cret Mar 25 '17 at 19:19
  • 1) Why code an applet? If it is due to the teacher specifying it, please refer them to [Why CS teachers should **stop** teaching Java applets](http://programmers.blogoverflow.com/2013/05/why-cs-teachers-should-stop-teaching-java-applets/). 2) See [Java Plugin support deprecated](http://www.gizmodo.com.au/2016/01/rest-in-hell-java-plug-in/) and [Moving to a Plugin-Free Web](https://blogs.oracle.com/java-platform-group/entry/moving_to_a_plugin_free). .. – Andrew Thompson Mar 26 '17 at 03:17
  • .. 3) It should be something more like `appletviewer [options] theHTMLthatLoadsJar.html`. See [appletviewer - The Java Applet Viewer](http://docs.oracle.com/javase/7/docs/technotes/tools/windows/appletviewer.html) for more details. – Andrew Thompson Mar 26 '17 at 03:17
  • So how could I open it via web browser? / What is an alternative to Applets? – sagi saadon Mar 26 '17 at 15:39

1 Answers1

0

Create a manifest file like this (manifest.mf)

Main-class: start.HelloWorld
Class-Path: /pathToYourExternalJars/XXXXX.jar /pathToYourExternalJars/XXXXX.jar

Here 'Main-class' is the starting point of your application (simply class which contains main method ) & 'Class-path' is for external jars which are included in your application (Optional)

srihari
  • 397
  • 2
  • 7
  • 18