Converting image to Jpeg2000 does not work

What am I doing wrong?

Nothing. The command you typed in is correct. The problem is that *.jp2 (JPEG 2000) support isn't built into the repository version of Imagemagick. When converting to an unsupported format the resulting destination file will be the same format as the source file.

You can verify this by looking at the fourth lines of the convert -version output:

$ convert -version

Output:

Version: ImageMagick 6.8.9-9 Q16 x86_64 2016-11-29 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules OpenMP
Delegates: bzlib cairo djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl lzma openexr pangocairo png rsvg tiff wmf x xml zlib

Notice that jp2 isn't included.

This is a reported bug (imagemagick: missing JPEG-2000 support):

The bug report describes the problem and indicates it has been fixed in the latest release (Version 6.9.1.2-1) which hasn't reached the repository yet.

Another test for jp2 support is:

$ identify -list format | egrep -i jp2

There is a use at your own risk PPA at:
https://launchpad.net/~isage-dna/+archive/ubuntu/imagick

Update:

As provided by SamWilson in the commands a supported PPA which I tested is located at: https://launchpad.net/~lyrasis/+archive/ubuntu/imagemagick-jp2

sudo add-apt-repository ppa:lyrasis/imagemagick-jp2
sudo apt-get update

Try this

convert example2.png -quality 0 example.jp2

This is still an issue as of February 2021. AFAIK JPEG 2000 support is disabled in Ubuntu due to a perceived risk of submarine patents.

However, there is a workaround that doesn't involve using third-party PPAs or compiling software yourself. The libopenjp2-tools package contains a decoding tool called opj_decompress that is able to convert .jp2 files into various lossless formats, including PNG, BMP, TIF, and RAW. It can even convert entire directories of files without the aid of external tools.

Convert a single file to TIF:

opj_decompress -i input.jp2 -o output.tif

Convert a directory of files to TIF:

opj_decompress -ImgDir my_jp2_images/ -OutFor TIF

Unfortunately, the native directory conversion isn't very fast due to it not being multithreaded. I've had to work on a large number of JPEG 2000 files over the years, and I've begun to use GNU Parallel to speed up the conversion process by using all the available CPU threads.

Converting all .jp2 files in a directory to .tif (need to be cd'd to the directory containing the files):

ls *.jp2 |parallel -j 10 --nice 19 --bar --will-cite "opj_decompress -i {} -o {}.tif"

Change the value of -j to however many threads want to use.

These files are very large since they don't use compression of any kind, so if you need to transfer them over a network or intend to store the them long-term, you might want to reduce their size by applying LZW compression:

ls *.tif |parallel -j 10 --nice 19 --bar --will-cite "mogrify -compress lzw {}"

In my experience, this can reduce file size by up to 50%.