Code blocks are the part of Markdown that works best in Jira: with two catches worth knowing before you paste a stack trace into a bug report.
Type three backticks at the start of a line and the editor converts it into a code block immediately. Everything you type after that stays inside the block, including characters that would otherwise autoformat.
That last point is the useful one: inside a code block, # and
* stay as themselves.
The language is a property of the code block node, chosen from a picker on the block itself. Typing the language after the opening fence (the usual Markdown habit) may not carry over on every input path, so check the block after creating it and set the language there if it did not take.
Single backticks around a word convert as you type. This is one of the most reliable conversions in the editor.
Pasting a whole fenced block, fences included, does not convert: the fence characters stay literal. Create the empty code block first, then paste your code into it. This also protects the code from being reformatted on the way in.
Wiki markup uses macros rather than fences:
{code:java}
System.out.println("hello");
{code}
{noformat}
plain preformatted text, no syntax highlighting
{noformat}
Inline code is {{double braces}}. Markdown backticks will not convert here.
These notes are written by sellerkit. We build a Markdown editor app for Jira (below), which is why we had to work all of this out in the first place.
Everything above this box works whether or not you install anything. Where a workaround is enough, we say so.