would guard against that.
If that's not working, as you say, then it must be somewhere else.
Can you post the error message and the lines of code that it points you to?

(look at the stack trace, it'll point you to various spots in the code - the topmost line of your code is usually the first place to look)

You could kludge around it - use some boolean "queueIsEmpty" which is initially true. If it's true, use an insert method that doesn't compare, just inserts, and then set queueIsEmpty to false, and it should work. However, that's not a very attractive solution.

Okay, my first assumption would be - having seen none of your code beyond a few snippets - that you've declared a PriorityQueue called "queue", but when you get to your line 71, that object has not been assigned to point to a correctly created PriorityQueue object on the heap.

There are a few ways that can happen. Let's take a look at your code - first thing I always look at is the main method.

What that line did was it declared a local variable called "queue" and pointed it to a new PriorityQueue of nodes. There was already a class field called queue, which this new variable shadowed - if there are two variables with the same name, the most local reference takes priority. Local variables go out of scope when their local context ends, in this case, when the constructor completes. So you created a Priority Queue, assigned it to a place on the stack, and then let it go out of scope. The field "queue" was never touched.

If the line reads

queue = new PriorityQueue<node>(n,compare);

then it's not declaring a variable, it's referring to one that already exists. Since there is such a variable in scope now, it finds it and uses it.

This gives you a little peek into the machine - you're seeing the difference between the local stack and the heap, and you're getting a sense of how scope and context work - so think about it a little bit. There's more here than just "okay, my program works now"!
But now your program should work, as well.