Question: I have built a simple GUI that takes in unorganized HTML code and organizes it...now that I have it working finally I need to learn how to distribute it. I managed to create my .jar file but when I try to run it I get "Error: could not find or failed to load main class HTMLFormatter.class"

Here's what I did:

First, I went to my "bin" folder in my project directory and copied all the applicable class files into another separate folder (cause i didn't want to accidentally mess up my original class files). In that separate folder I also created manifest.txt which contains:

```
Manifest-Version: 1.0
Main-Class: HTMLFormatter.class
Class-Path: .

```

Then I ran this command from that directory: 

```
jar cfm HTMLFormatter.jar manifest.txt ./*.class

```

This created the JAR just fine, I used winrar to peek inside and it contained all the proper class files and the manifest was in META-INF directory. Then I tried to run it, first by double clicking, though I'm not even sure if that is SUPPOSED to work...Then I tried running it via command line using this command:

```
java -jar HTMLFormatter.jar

```

Which is when I got the error message. Then I read a post from this site that implied windows sometimes uses javaw instead... so i used the same command above with javaw and it didn't give me an error, but it still didn't produce my GUI.

So, what am I missing? also when I finally figure this out, should I be able to just double-click the jar file? (windows 8.1 64bit in case it matters)

Answer: 
`.npy` files contain header which has shape and dtype of the array in it. If you know what your resulting array looks like, you can write header yourself and then data in chunks. E.g., here is the code for concatenating 2d matrices:

```
import numpy as np
import numpy.lib.format as fmt

def get_header(fnames):
    dtype = None
    shape_0 = 0
    shape_1 = None
    for i, fname in enumerate(fnames):
        m = np.load(fname, mmap_mode='r') # mmap so we read only header really fast
        if i == 0:
            dtype = m.dtype
            shape_1 = m.shape[1]
        else:
            assert m.dtype == dtype
            assert m.shape[1] == shape_1
        shape_0 += m.shape[0]
    return {'descr': fmt.dtype_to_descr(dtype), 'fortran_order': False, 'shape': (shape_0, shape_1)}

def concatenate(res_fname, input_fnames):
    header = get_header(input_fnames)
    with open(res_fname, 'wb') as f:
        fmt.write_array_header_2_0(f, header)
        for fname in input_fnames:
            m = np.load(fname)
            f.write(m.tostring('C'))

```

If you need a more general solution (edit header in place while appending) you'll have to resort to `fseek` tricks like in [1].

Inspired by  

[1]: <https://mail.scipy.org/pipermail/numpy-discussion/2009-August/044570.html> (doesn't work out of the box)  

[2]: <https://docs.scipy.org/doc/numpy/neps/npy-format.html>  

[3]: <https://github.com/numpy/numpy/blob/master/numpy/lib/format.py>
For appending data to an already existing file using numpy.save, we should use:

```
f_handle = file(filename, 'a')
numpy.save(f_handle, arr)
f_handle.close()

```

I have checked that it works in python 2.7 and numpy 1.10.4

I have adapted the code from [here](https://mail.scipy.org/pipermail/numpy-discussion/2007-November/030099.html), which talks about savetxt method.