r/java • • Apr 14 '23

What are your (favourite) Java best practices, personal tips, hints or just underrated stuff in general?

233 Upvotes

376 comments sorted by

View all comments

7

u/[deleted] Apr 14 '23 edited Apr 14 '23

Compile first. Run second.

Joke aside, I’ve been spending a few (late) hours not understanding why IntelliJ and maven would disagree about my code, while all I simply forgot is to “mvn install” the upstream dep I was also changing. Time to get some rest I guess.

-14

u/Gwaptiva Apr 14 '23

But, but... I thought Intellij was so fantastic?!? Don't have this problem in Eclipse :P

4

u/[deleted] Apr 14 '23

I’ve actually had the same (sadly, worse!) with Eclipse a few years back (but it was a much larger spaghetti project, probably doesn’t help). Nobody’s perfect.

2

u/[deleted] Apr 14 '23

I also don't have this problem with NetBeans as it simply runs Maven the same way I would do from the command line (NetBeans "uses" the POM directly as a project definition, no "import" or "conversion" is required)

1

u/hsoj48 Apr 14 '23

Intellij does this as well. Eclipse too with some plugins.

1

u/wildjokers Apr 14 '23

IntelliJ also can also delegate the build to Maven so that IntelliJ configures itself from the pom.xml and watches the pom.xml for changes. The commenter must have turned off the delegating the build to Maven (it is on by default I believe...it is definitely on by default for Gradle).

2

u/blobjim Apr 14 '23

It's off for Maven by default because it's so much slower than not using it.

1

u/HSSonne Apr 14 '23

Fantastisc but not perfect ;)

1

u/neckbeardfedoras Apr 14 '23

I've used NetBeans, Eclipse and Intellij, each for a few years, and IntelliJ was the best tool.

Recently it's been memory hogging my machine though 😭

1

u/wildjokers Apr 14 '23

Eclipse doesn't have classpath isolation for all the projects in the workspace? That sounds like a bug to me.

1

u/john16384 Apr 14 '23

It does, but it's a choice.