Showing posts with label ide. Show all posts
Showing posts with label ide. Show all posts

Monday, 26 January 2026

Git: Cleaning up

Sometimes, our IDE can make a mess of things (mostly because we did something wrong, though).

And in order to fix it, sometimes we have to get rid of all unversioned files, so that we have a clean git repository and then create a new Project in our IDE.

This helps as it forces the IDE to recreate its config files from scratch.

This blog is just a small note on how to clean your git repository of all unversioned files.

A dry run would look like this:

git clean -n -x -d

A proper clean would look like this:

git clean -d -x

Options:

-n
dry run
-d
also recursively delete unversioned directories.
-x
ignore .git-ignore rules (convenient for cleaning up buildproducts and IDE config files)

Output of a dry run would look something like this:

% git clean -n -x -d
Would remove .DS_Store
Would remove .idea/
Would remove mrbear-parent/mrbear-app/target/
Would remove mrbear-stubs/.gradle/
Would remove mrbear-stubs/.kotlin/
Would remove mrbear-stubs/build/

See also "git restore" or "git reset".

References

git-clean - Remove untracked files from the working tree
https://git-scm.com/docs/git-clean

Thursday, 10 July 2025

@Nonnull versus @NotNull

A quick small blog...

So, we have two (seemingly) conflicting annotations for the same thing1.

Even people who know exactly when to use what have a chance to pick the wrong one, especially with the use of Code Completion and AI nowadays.

So here's a quick rundown, but the reference below is much more in depth:

import javax.annotation.Nonnull;

@Nonnull
IDEs and Compilers use it for Static Analysis of code. (Though the RetentionPolicy is set to RUNTIME)
import jakarta.validation.constraints.NotNull;

@NotNull
Validation Frameworks (like ORMs) use it during Runtime for checks.

What about Nullable values?

import javax.annotation.Nullable;

@Nullable
IDEs and Compilers use it for Static Analysis of code.

There is no @Nullable available for jakarta.validation.constraints. By default things are nullable, unless explicitly mentioned otherwise.

When not to use @NotNull

The primary really important thing to take away from this is to not do the following:

It might work, your IDE might complain or it might not, but at runtime this will be ignored, unless this method is called by a Framework as mentioned above.

Addendum

Don't use javax.validation.constraints.NotNull. It's been superseded by Jakarta when Oracle moved Java EE to Jakarta. See [2].

Referenties

[1] Medium - Understanding @NotNull vs @Nonnull in Java: A Practical Guide to Null-Safety
https://medium.com/@mesfandiari77/understanding-notnull-vs-nonnull-in-java-a-practical-guide-to-null-safety-5e179e918f37
[2] Medium - Difference between javax.validation and jakarta.validation
https://medium.com/@ovinduuu/difference-between-javax-validation-and-jakarta-validation-df0c6dbe5cb3

Thursday, 26 December 2024

Reinitializing IntelliJ

Every once in a while, you get into trouble, serious trouble, and the only solution is to clear out all your stuff and start again.

This recently happened to me when my IntelliJ started misbehaving. I didn't have time to fix it, so I just bore with it, but now it's time to fix it.

In order to remove all the settings of IntelliJ (That I thought were the problem), I found the link at [2] via [1] which helped a lot!

And since I'm using a MacBook M2, perhaps I should write them down here:

Configuration (idea.config.path): ~/Library/Application Support/JetBrains/IntelliJIdea2022.2
Plugins (idea.plugins.path): ~/Library/Application Support/JetBrains/IntelliJIdea2022.2/plugins
System (idea.system.path): ~/Library/Caches/JetBrains/IntelliJIdea2022.2
Logs (idea.log.path): ~/Library/Logs/JetBrains/IntelliJIdea2022.2
Preferences (~/Library/Preferences/com.jetbrains.*)

Above are the directories that you should either remove or move somewhere safe (in case you want to reuse settings, like for example database connection properties).

Removing installed applications

JetBrains Toolbox

I found a good reference to it in [4].

Removing IntelliJ settings from a Project

So, if I've done the above, good idea to also remove the settings that are project specific.

This should be as simple as finding the ".idea" directory in your project and removing it entirely. But an alternate way is just removing all unversioned files and changes from your version management system, that'll work too.

I found a good way of doing it using the Git versioning system and described it in [3].

Then what?

Well, unfortunately, after all that it's time to reimport your project into IntelliJ and configuring all your IntelliJ settings again.

Preferably by hand, to prevent the same problem that torpedoed your Intellij from happening again.

References

[1] StackOverflow - In IntelliJ on OS X, how do you clear out all global setting info, licensing etc. (external to any project)
https://stackoverflow.com/questions/2774315/in-intellij-on-os-x-how-do-you-clear-out-all-global-setting-info-licensing-etc
[2] IntelliJ Support - Directories used by the IDE to store settings, caches, plugins and logs
https://intellij-support.jetbrains.com/hc/en-us/articles/206544519-Directories-used-by-the-IDE-to-store-settings-caches-plugins-and-logs
[3] Git: Adding your own commands
https://randomthoughtsonjavaprogramming.blogspot.com/2024/10/git-adding-your-own-commands.html
[4] iBoostUp - How To Uninstall JetBrains Toolbox
https://www.iboostup.com/how-to-uninstall/com.jetbrains.apps.activator

Monday, 2 October 2017

Running Java Programs Online

I have been looking around for an online Java IDE (Integrated Development Environment), so I can do my programming whenever whereever.

Now there are a lot of free websites available where you can just paste a bunch of java code and have it run. Usually it means having all your java code (classes and everything) inside what is basically a TextArea in the browser. An example of these are listed here with my general view of them.

At the bottom are two options that seem to go more towards a full IDE.

Java Online Compiler
https://www.javaonlinecompiler.com/
Nice with a Java tutorial to work alongside.
Codingground - Compile and Execute Java Online (JDK 1.8.0)
https://www.tutorialspoint.com/compile_java_online.php
Seems to have a very nice clean layout.
CompileJava
https://www.compilejava.net/
It seems like a very bare-bones version.
ideone.com
https://ideone.com/
Very few features and the advertising gets annoying quick.
Browxy
http://www.browxy.com/
Seems good. The ability to run your program as an applet is a nice touch. Looks a little more impressive than the other options here.
Guru99
http://www.guru99.com/try-java-editor.html
The absolute minimum to run a Java program and the advertising is annoying.
CodeChef
https://www.codechef.com/ide
A very clean interface. Every programming language known to man available at your fingertips. Ability to upload programs. Used for practice and for competition.
remoteinterview.io Online IDED for Java
https://www.remoteinterview.io/online-java-compiler
Seems okay, but it is great for mob programming. You can invite your friends and you can hack together in the same program. Can handle many programming languages. Very nice interface, autocomplete and code colours. Seems to be used for interviewing potential software designers.
JDoodle
https://www.jdoodle.com/online-java-compiler
Seems to have only few features. However, you can add Maven external libraries which is nice.

Codiva

Codiva at https://www.codiva.io is very nice. It is one of the only ones that I could find that had a very low threshold (you can just try it, you can create an account if you like, but you are not required to) and it is one of the few ones where you can actually create different files, instead of putting all your code into a textarea. It also comes with code highlighting and code completion.

Codenvy

Codenvy seems to be an even more professional IDE, where not only do you have a programming environment, but you actually have a Docker image and stuff. It's available at https://codenvy.io.

I shall examine other highend options where a really full fledged IDE is available in your browser in a later blogpost.