A survey from Tidelift and The New Stack found that developers spend 76% of their time writing, improving or testing code. 76%!!
Since you’re going to spend three-quarters of your time working with code, you might as well try to make that time more productive and enjoyable, right?
That’s why most people use an Integrated Development Environment, or IDE, to write code.
In this article, we’re going to see why you should use an IDE to write Java, and I’m going to save you a ton of time and tell you exactly which IDE you should use to write awesome Java programs.
Java IDEs 101
Let’s have a look at IDEs in general, what they are and whether you need one.
What is an IDE?
An IDE, or Integrated Development Environment, is a program that helps you write software. An IDE helps you to organise your software projects, write code, test and debug.
An IDE is usually responsible for these things:
Do you need an IDE to write Java code?
Let me be absolutely clear upfront.
Java doesn’t require an IDE. You don’t need an IDE to be an amazing Java developer.
In fact, I’ve met Java developers who use Vim to write Java code, and then use the Terminal to run it all. And they write excellent code. (You can even use Vim as a Java IDE)
Java is written in plain text files, and then compiled separately. So you could write code for the Mars rover, nuclear power stations, or even quantum trading algorithms, with good old Windows Notepad, and
And when you’re a Java beginner, it will be better for your learning if you just write code using a text editor, and compile and run it using
But, once you’ve moved on from the beginner stage, you will probably benefit from using some kind of graphical desktop program that helps you to write code.
An IDE helps you organise your project, run tests, compile the code and much more.
Now you’ve decided you want a Java IDE. That’s why you’re reading this article! (Hi!)
So how do you pick one? What are the features to look for in a good Java IDE? We’ll look at that next.
Choosing an IDE
If you have the freedom to choose an IDE, then you’re probably wondering what to look for.
What makes a great Java IDE
A developer’s choice of IDE can be a very personal thing. (See my example above about a developer who prefers to write code using Vim!).
But here’s what I expect any IDE to be:
FAST. It has to be fast. Faster than Speedy Gonzales. Every second you spend waiting for your IDE to process a file, is a second that you might lose concentration or train of thought.
STABLE. It has to be able to handle multiple editor windows, terminals and build processes simultaneously. And it must handle all of that, without freezing or crashing.
INTELLIGENT. A good Java IDE knows how to take care of boring, repetitive tasks, but it also knows to get out of your way when you just need to write code. I don’t want to battle a bunch of wizards and dialog boxes all the time, just give me some sensible default options.
KNOWLEDGEABLE. The IDE should know what good code looks like, and help me avoid code smells – those pieces of code which aren’t great. It should also help me to optimise, by suggesting more succinct alternatives for what I’m writing.
MODERN. Java has traditionally been a slowly-evolving language, but the releases have picked up the pace in recent years, and now we see a new Long-Term Support release of Java every 3 years. Any Java IDE needs to be able to handle the modern features and frameworks of Java 11, 14 and beyond.
ERGONOMIC. This is a fancy way of saying that the IDE should feel great to use.
A great IDE helps you automate boring tasks, but also gets out of the way when you need to concentrate and write code.
Does having a good IDE make any difference?
If the code is the same, then does it really matter which IDE you use?
Researchers at Microsoft and the University of Victoria BC conducted a survey of engineers.
They found that engineers rank poor engineering tools as one of their biggest challenges they face in their job. It’s a bigger challenge even than things like their manager or experiencing too many interruptions.
These challenges impede engineers’ satisfaction and productivity.
So, having decent tools for the job really matters.
What if I can’t choose my own IDE?
If you’re learning Java in your spare time, then you’ve probably got the freedom to choose.
If you’re about to accept a job as a Java developer, and they don’t allow you to choose your own IDE, I would challenge it.
You’re going to be spending up to 8 HOURS per day with this application. It needs to help you do great work.
The most popular Java IDEs
So now let’s look at the top 5 IDEs used by Java developers these days:
Oracle JDeveloper, Eclipse, NetBeans, Visual Studio Code and IntelliJ IDEA
(I include Android Studio with IntelliJ IDEA)
Here’s my breakdown of these 5 Java IDEs:
|IDE||My review||My rating|
|JDeveloper||The “J” is short for “joke”. Crashes constantly, be prepared to lose all your work and leave the office every day, empty and unfulfilled. Only use if it’s forced upon you at gun-point, or via an Oracle license.||★|
|Eclipse||Crashes frequently. Easy to get lost with Perspectives. Slow, just terribly slow.||★★|
|NetBeans||Acceptable, but hasn’t kept up the pace with modern Java developers’ needs.||★★★|
|Visual Studio Code||A solid “good”. Does most of the things you will need. But it’s still just a text editor at heart, with added bells and whistles.||★★★★|
|IntelliJ IDEA||A fast and productive environment to work in. Full insights into your code. First-class debugging, testing, decompiling.||★★★★★|
The best desktop Java IDE: IntelliJ IDEA
After years of trying out each of the different top Java IDEs, I’ve settled on my recommended choice.
The best desktop Java IDE in 2021 is…. IntelliJ IDEA. 🙇♂️
I’ve spent the last 10+ years developing with Java. I’ve tried all the big five – NetBeans, Eclipse, Visual Studio Code, JDeveloper and IntelliJ – and I have not found another desktop IDE that beats IntelliJ for productivity and speed.
- FREE and Open Source - the Community Edition has all you need
- Available for Windows, Mac and Linux
- Fast.... like light-speed fast
- First class support for Maven
- Awesome built-in code inspection, testing, debugging and decompiling tools
- If you're doing Android development, then check out Android Studio -- it's based on the same technology
Why it’s a great choice
Here are some of the features in IntelliJ that make me think it’s the best Java IDE:
Fast global search
Using fuzzy search you can quickly go to any piece of code in your project.
This means less time fiddling around in the project tree, trying to remember where that class went.
You can also use this feature to instantly decompile your dependencies and have a look at the source code.
Just press Left Shift twice to activate global search:
Solid plugin ecosystem
IntelliJ is extensible with plugins. I use the Apache Camel plugin all the time, for example.
But my favourite plugin is the Nyancat plugin. Get a flying rainbow cat in your IDE, While-U-Wait:
Amazing unit test runner
Once you start writing unit tests for your Java applications, and start running them in IntelliJ, you won’t want to run them any other way.
They run quickly, and you can also debug your tests very easily.
Which brings me on to…
Great debugger and decompiler
Once you start creating complex programs, or using external frameworks, you’re going to need a solid debugger and decompiler.
The decompiler allows you to see the source code of the classes you’re using, so you can figure out what’s really going on, in any library you’re using.
In the debugger, you can inspect any object, step forward and back through code lines, and more:
Both of these features are absolutely amazing in IntelliJ, and I would be far less productive if I didn’t have them.
First-class support for Maven
IntelliJ’s support for Maven is great, and specifically the Maven tool window is a blessing for me.
It helps me to visualise all of my dependencies, goals (the “executions” that you run in Maven) and more.
Watch my short video on how to understand a Maven project with IntelliJ IDEA:
In all the years I’ve used it, I’ve had very few crashes. When I use Eclipse, I tend to get poor performance and crashes (sorry Eclipse!)
Automatic code formatting, with sensible defaults
One of the annoying things about other IDEs is that they don’t take a strong stand on code formatting.
Well-formatted code makes it so much easier to share and collaborate with other members of your team!
If code isn’t formatted correctly, you can literally waste time when you’re learning someone else’s codebase. You have to figure out their weird formatting approach, or why some files have been indented with Spaces and some have been indented with Tabs.
(By the way: you make more money if you indent with spaces.)
IntelliJ formats everything as you type, and will even format code you paste from the clipboard.
This is crucial when you’re working as a team. You don’t want to be that developer, whose code everyone else struggles to read because it’s not formatted correctly and looks weird.
Do you need the (paid) IntelliJ Ultimate Edition?
I don’t think you will even need the Ultimate (premium) edition of IntelliJ.
I’ve used the Community (free) edition for 5 years. I’ve never paid for the Ultimate Edition, and I’ve written and debugged code for various platforms like Spring, JBoss, OSGi and more.
The verdict on IntelliJ
I don’t even own a paid licence for IntelliJ IDEA; I use the Community Edition. But I think it is truly the best IDE for professional Java developers.
IntelliJ has helped me become massively more productive as a Java developer. Not only can I write code quicker, but my debugging and problem-solving (which is how I spend a lot of my time) is made much easier too.
The reasons I recommend IntelliJ is because of its speed, stability and awesome testing and debugging features. But primarily because it’s fast and stable. (Did I say it’s stable?)
If you’ve graduated from beginner Java, and you’re looking for an IDE which will support you in writing great Java programs, then you should definitely think about IntelliJ.
Best Java code editor: Visual Studio Code
If you don’t want a full-blown IDE, but you want to be able to write Java code, then there is a decent alternative to IntelliJ IDEA, which comes in second place overall:
It’s Visual Studio Code with the Java Extension Pack.
- Available for Windows, Mac and Linux
- Install the Java Extension Pack to get support for Java linting & refactoring, Maven and debugging support
- Not as feature-rich as IntelliJ, but good for day-to-day coding
I call VS Code a code editor with Java support features, rather than a full-blown Java IDE. This is because, first and foremost, it is a text editor which can be expanded with extensions.
VS Code is great…. but…. it just doesn’t understand Java as well as IntelliJ. What I mean by that is, it doesn’t have the same level of deep understanding of your code, and the whole Java ecosystem.
You can achieve a lot of the same features as IntelliJ by installing plugins, but my view is that these features should be built-in to the IDE, and not left to individual plugin contributors to write.
I’m sure at some point, VS Code will have Java support to rival IntelliJ IDEA. But, until then, I’m sticking with IntelliJ IDEA as my Java IDE recommendation, and VS Code as a solid second place.
Best tools to run Java code online: REPL.it & openshift.io
If you’re a beginner looking to learn Java, and you can’t install the Java Development Kit, you can still write Java programs in a web browser.
REPL.it allows you to do that. It allows you to run simple Java programs online, in your web browser.
- FREE on the Starter Plan
- Works in your web browser
- Paid option available, for private code, or if you want more storage and resources
- Great for simple programs and learning
Bear in mind that as Java is a compiled language, there is a delay between pressing the Run button and seeing your program’s output. This is because the server has to compile your program first.
Repl.it is the best balanced, easy-to-use online Java code runner. It supports lots of different languages, Java is just one of them.
It’s ahead of other online Java environments, because it supports Java 11. Many others are old and only support Java 8.
The free tier in Repl.it allows you to create unlimited public projects.
You edit your code in an editor like this:
And then press Run to see it compiled and executed.
You don’t need to install a plugin or any custom software on your laptop.
Repl.it isn’t suitable for complex applications, because you can’t import classes. But, with a little work, you can even create applications that use dependencies from Maven.
You can have a play with an embedded REPL.it here. This is a Java application with a
main class, which starts Apache Camel:
My other recommendation is Openshift.io. This is a full cloud-hosted IDE that’s based on Eclipse Che.
- FREE basic developer tier
- Up to 1GB of memory and storage
- Good for developing webapps
- Cloud-based IDE, with full Maven functionality and terminal
The great thing about Openshift.io is that it’s like a full Java IDE in your browser. You can pull dependencies, develop and run web apps right inside the cloud.
The free tier from Red Hat gives you up to 1GB of memory and storage, which is good for small projects or for testing the service out.
So there you have it. My recommended IDE for desktop-based Java development is IntelliJ IDEA.
If you prefer a code editor with additional Java support features, then I recommend Visual Studio Code with the Java Extension Pack.
And finally if you want to do some simple online Java coding, then use REPL.it or Openshift.io.
Now you’ve seen my recommendations, what are you waiting for?
Let’s go and write some awesome Java code!
Got any thoughts on what you've just read? Anything wrong, or no longer correct? Sign in with your GitHub account to leave a comment.
(All comments get added as Issues in our GitHub repo here, using the comments tool Utterances)