How can I create an executable JAR with dependencies using Maven?

I want to package my project in a single executable JAR for distribution. How can I make Maven package all dependency JARs into my JAR?

and you run it with

Compile goal should be added before assembly:single or […]

Initialization of an ArrayList in one line

I want to create a list of options for testing purposes. At first, I did this:

Then I refactored the code as follows:

Is there a better way to do this? Actually, probably the “best” way to initialize […]

Why is printing “B” dramatically slower than printing “#”?

I generated two matrices of 1000 x 1000: First Matrix: O and #. Second Matrix: O and B. Using the following code, the first matrix took 8.52 seconds to complete:

With this code, the second matrix took 259.152 seconds […]

When to use LinkedList over ArrayList?

I’ve always been one to simply use:

I use the interface as the type name for portability, so that when I ask questions such as these I can rework my code. When should LinkedList be used over ArrayList and […]

Iterate through a HashMap

Possible Duplicate: How do I iterate over each Entry in a Collection Map? What’s the best way to iterate over the items in a HashMap? Iterate through the entrySet like so:

Read more on Map     Source

event.preventDefault() vs. return false

When I want to prevent other event handlers from executing after a certain event is fired, I can use one of two techniques. I’ll use jQuery in the examples, but this applies to plain-JS as well: 1. event.preventDefault()

2. […]