title: How do I inject new manifest into an existing jar for applet
body: <p>I have a website that has been working for years (2). But since the new java restrictions (January 2014), my applet is blocked. So after doing some reading, it seems all I have to do is change the manifest file; I don't even need to recompile the code. (If I am wrong about this, please correct me.)</p>
  
  <p>So I have created the following manifest file</p>
  
  <pre><code>Manifest-Version: 1.0
  Created-By: 1.7.0_51
  Permissions: sandbox
  Application-Name: MyFarmingBusiness
  Application-Library-Allowable-Codebase:http://mycompany.com/version_4/myapplet/
  Caller-Allowable-Codebase:www.mycompany.com
  Codebase: www.mycompany.com
  </code></pre>
  
  <p>Then to inject the manifest into my jar</p>
  
  <ul>
  <li>I save the manifest.txt file in the same directory as the jar</li>
  <li>then in mac osx terminal I type: `jar cfm MyGreat.jar manifest.txt </li>
  </ul>
  
  <p>As a result, I get the following error</p>
  
  <pre><code>java.io.IOException: invalid header field
  at java.util.jar.Attributes.read(Attributes.java:410)
  at java.util.jar.Manifest.read(Manifest.java:199)
  at java.util.jar.Manifest.&lt;init&gt;(Manifest.java:69)
  at sun.tools.jar.Main.run(Main.java:172)
  at sun.tools.jar.Main.main(Main.java:1177)
  </code></pre>
  
  <p>Does anyone know how to fix this?</p>
  
  <p>Another approach might be to recreate the jar anew.
  So I did the following</p>
  
  <ul>
  <li>to extract the source:  <code>jar xf MyGreat.jar</code></li>
  <li>but then, I haven't done this in so long, I don't know how to reconstruct the jar from the source: the source only contains <code>.class</code> files in directory <code>com/mycompany/...</code> and the manifest in a directory called <code>META-INF</code>. I try searching online, but I haven't had much luck on how to do this from terminal.</li>
  </ul>
  
  <p>So maybe someone can tell me how to create a jar with manifest from terminal. I know the command: <code>jar cvf MyGreat.jar MyGreat</code></p>
  
  <p>But how do I get the manifest in? where to I put the manifest with respect to the <code>.class</code> files so that in the end, I get a jar file with directories: <code>com</code> and <code>META-INF</code></p>