dpkg error: "trying to overwrite file, which is also in..."

To fix your problem run

sudo dpkg -i --force-overwrite /var/cache/apt/archives/libjline-java_1.0-1_all.deb

check everything is fixed by running : sudo apt-get -f install

If you still have problems rerun the first step with any dpkg: error processing (...) remaining

Solution found on webupd8


Please don't go for the danjjl answer directly, if you face this kind of "trying to overwrite" error, is likely that you have conflicting packages that need to be solved first.

The immediate fix for the issue is to remove the conflicting package that is undesirable, in this case scala,

sudo dpkg -P scala

Next it would be recommended to submit a bug report with the respective package maintainers. This normally imply adding a Conflict: package line in the control file.

Also see this answer for more detailed explanation about this error.


@danjjl's command works for .deb files. I found this command works with apt/apt-get:

sudo apt-get -o Dpkg::Options::="--force-overwrite" install <package-name>