How to Diff Java Code in IntelliJ - 3 ways to use the Compare Tool
TL;DR IntelliJ has an inbuilt diff tool which you can use to compare files, classes or code with the clipboard. Just right click and choose Compare.

I was busy refactoring code in RestMud this morning because I want to try and open source the basic game engine, and then later the Web/REST API, but I want to tidy up the code a little first.
I’ve been working through the code:
- moving classes into new packages
- splitting classes to make code clearer and easier to manage
- new classes make code easier to test
And the more I tidy it up in general, the easier it is to spot smaller problems of code duplication.
Java 1.9 Reflection and Package Access Changes
TL;DR Java 1.9 does not like reflection as much as previous versions and access to proprietary packages is not possible out of the box.

Java 1.9 is out, and many companies now will be evaluating Java 1.9 and migrating their code base over to Java 1.9. I am now going through a similar process.
I have some fairly simple code that I was using for HTTP requests. This was originally written in Java 1.8 and to keep my codebase as simple as possible and I wanted to use no external libraries, therefore for HTTP requests I used an HttpURLConnection.
This started to fail on Java 1.9.
When I looked in my code more carefully I realised that it wasn’t HttpURLConnection that was failing in Java 1.9 it was my use of Reflection to bypass some constraints of the HttpUrlConnection that was failing.
Why does my code throw a null pointer exception? - common reason
TLDR; check that you haven’t redeclared a field as a variable in a setup method
FAQ - why does my code throw a null pointer exception - common reason #1 Redeclaration
- Using
@BeforeClassor@Beforecan setup data for use in tests - Any ‘variables’ we instantiate need to be ‘fields’ rather than variables
- We want to instantiate them in the setup method rather than redeclare them
An introduction to Refactoring Java in IntelliJ using RestMud as an Example
TL;DR Never too late to refactor. Do it in small chunks. Protected by tests. Using IDE to refactor.
JSoup Tip How to get raw element text with newlines in Java - Parsing HTML and XML with JSoup
TL;DR with JSoup either switch off document pretty printing or use textNodes to pull the raw text from an element.
Mistakes using Java main and examples of coding without main
TL;DR A potentially contentious post where I describe how I’ve survived without writing a lot of Java main methods, and how learning from code that is often driven by a main method has not helped some people. I do not argue for not learning how to write main methods. I do not argue against main methods. I argue for learning them later, after you know how to code Java. I argue for learning how to use test runners and built in features of maven or other build tools to execute your @Test code.
Let's Code - Binary Chopifier - Just Enough Code and Tooling to Start
TLDR; “Let’s code a Binary Chopifier” which I plan, code as prototype to plan in an @Test method, test interactively, experiment, and release as an @Test.
How to create and release a jar to maven central
TLDR; The instructions on apache and sonatype site are pretty good to help get library released to maven central. But you’ll need to learn about pgp signing and might need more rigour in your pom file. A fairly painless learning process that I recommend you go through and release something to the world.
How to fix IntelliJ issues by looking in the IntelliJ log
TLDR; View the IntelliJ log Help -> ‘Show Log in Explorer’
How to convert a breakpoint into a conditional breakpoint in IntelliJ
TLDR; right click on a breakpoint and add code that returns a boolean to make it a conditional breakpoint


