I’ve used NetBeans very briefly around 2006 or 2007, can’t remember exactly, so I’m not the best person to talk about it. Geertjan was kind enough to collaborate with my Java Tip of the Week and make a video with me while going through some of the NetBeans features. I was also very happy to have my first guest speaker in my videos.
I have to say that I was very surprised with NetBeans. I would definitely keep an eye on it and maybe use it for some stuff. Just watch the video and decide for yourself:
Do we have someone that wants to make an Eclipse one to complete the set? I’ll be happy to do it.
In the meanwhile, emember to follow my Youtube channel for faster updates!
Leave a comment if you enjoyed it, if not leave one as well!
It’s not secret that my favourite IDE is IntelliJ IDEA. You have already seen me using it in my previous videos, so it was just a matter of time to bring it as a topic. Here it is! Not trying to convince anyone to change or to start an IDE flame war. It’s enough already with the Java EE vs Spring wars.
Anyway, in a bit longer than 5 minutes this time, I went through some of the features that I use the most in IntelliJ, on Navigation and Code Generation.
Here is the video:
Here are also some other posts I’ve wrote about IntelliJ:
Before Java 8, Interfaces were a closed contract, meaning that after you published an Interface, every implementation would have to implement every method present in the Interface. If you changed your mind later and wanted to add new methods, you couldn’t without breaking the compatibility. Implementations would need to add the missing code to the new methods. The Collections API is a good example. It was designed since the early versions of Java, but it was missing operations that would help every day developer.
With Java 8, we can now implement methods in the Interface directly. This is done via a Default Method with the default keyword. As the name says, we are providing a default implementation for the method. So, if any implementation does not implement the method, it would use the default implementation. This change allowed to expand and extend API’s behaviour without breaking compatibility.
Default Method Interface
Here is a sample:
Action Interface
Java
1
2
3
4
5
6
7
publicinterfaceAction{
voiddoSomething();
defaultvoiddoSomethingMore(){
System.out.println("Do Something More from Action");
}
}
Action Implementation
Java
1
2
3
4
5
6
7
8
9
10
11
12
13
publicclassMainimplementsAction{
publicstaticvoidmain(String[]args){
Main main=newMain();
main.doSomething();
main.doSomethingMore();
}
@Override
publicvoiddoSomething(){
System.out.println("Do Something");
}
}
Yes, this works!
Check out this video with some live coding examples:
This week Java Tip of the Week is a follow up of last session about Maven. The first video covered aspects related to Maven Dependencies. This video will cover some techniques to speed up your Maven build.
Maven Slow?
Since Maven 3, you are able to run your builds in parallel. Depending on the build machine and the project structure, you might get a 60% speedup increase!
Also, there are some ways to selectively pick just the things you want to build, using the -amd and -am flags. These are available since Maven 2, but for some reason they don’t seem to be used that much.
Check the video:
For reference, here are the commands:
Command
Description
mvn clean install -T 1C
Builds the project with one Thread per Core
mvn clean install -T 2C
Builds the project with two Threads per Core
mvn clean install -T 4
Builds the project with fours Threads
mvn clean install -pl [project-name] -amd
Builds just the project specified in -pl and all the dependent projects.
mvn clean install -pl [project-name] -am
Builds just the project specified in -pl and all the required projects to build it.
This week Java Tip of the Week is about Maven. I’ve recently had session at Jfokus, called Maven Taming the Beast with the following abstract:
Maven Taming the Beast
Love it or hate it (and a lot of people seem to hate it), Maven is a widely used tool. We can consider that Maven has been the de-facto standard build tool for Java over the last 10 years. Most experienced developers already got their share of Maven headaches. Unfortunately, new developers are going through the same hard learning process, because they don’t know how to deal with Maven particularities. “Why is this jar in my build?”, “I can’t see my changes!”, “The jar is not included in the distribution!”, “The artifact was not found!” are common problems. Learn to tame the Maven Beast and be in complete control of your build to save you countless hours of pain and frustration.
Since the presentation was only 15 minutes long (video should be available later), I made this week Java Tip of the Week a small demo of some of the issues discussed and the commands you can use to fix them:
For reference, here are the commands:
Command
Description
mvn dependency:list
Displays the list of dependencies for the project.
mvn dependency:tree
Displays the dependency tree for the project, including transitive dependencies.
mvn dependency:analyze
Analyzes the dependencies of the project and determines which are: used and declared; used and undeclared; unused and declared.
mvn dependency:tree -Dverbose
Displays the dependency tree for the project, including transitive dependencies and omitted dependencies due to Dependency Mediation.
mvn install -Dmaven.repo.local=/tmp/.m2
Points Maven local repository to a new directory, forcing Maven to download everything again.