Ant not working in Ubuntu/Kubuntu 20.04 LTS

After a clean installation of a Kubuntu 29.04 LTS, Ant was not working properly. A simple ant -version came out as

/bin/ant: 1: cd: can't cd to /bin/../share/ant/bin/..
Error: Could not find or load main class org.apache.tools.ant.launch.Launcher
Caused by: java.lang.ClassNotFoundException: org.apache.tools.ant.launch.Launcher

One may think the problem resides in the ANT_HOME not being set, but actually the problem is that Ant is not pointing to the correct location.

The solution was quite simple, the incorrect symbolic link was removed and a new one was created pointing it to the correct location:

sudo rm -rf /bin/ant
sudo ln -s /usr/share/ant/bin/ant /bin/ant

Please note that this solution worked for me, check if it works for you to before making any system changes.

./M6