I want to install JDK for Debian using ARM64 but I got todpkg: error: archive 'jdk-20.0.2' is not a regular file, how do I fix?

360 Views Asked by At

I tried to install Java IDK using https://www.oracle.com/java/technologies/downloads/#jdk18-linux and wget as well as uncompressing it using tar but when I tried to sudo apt dpkg install on it, it would result in the error:

dpkg: error: 
archive 'jdk-20.0.2' is not a regular file. 

What does it mean and how can I fix it?

  1. Installed https://www.oracle.com/java/technologies/downloads/#jdk18-linux using wget
  2. Got back jdk-20_linux-aarch64_bin.tar.gz, then went to Downloads directory
  3. Unpackaged jdk-20_linux-aarch64_bin.tar.gz using tar zxvf
  4. Tried to sudo dpkg -i jdk-20_linux-aarch64_bin.tar.gz
  5. "dpkg: error: archive 'jdk-20.0.2' is not a regular file"
1

There are 1 best solutions below

5
Shovel_Knight On

You cannot install a tar.gz file using dpkg — it's not a .deb package, and dpkg does not know what to do with it.

If you only need to install Java for your user and not systemwide, you could do the following:

tar -xzvf jdk-20_linux-aarch64_bin.tar.gz

This would extract the contents of the archive into a directory called jdk-20.0.2. Now create the .bin/java directory in your home folder:

mkdir -p ~/.bin/java

Now copy the jdk-20.0.2 folder into your new folder:

cp -rp jdk-20.0.2 ~/.bin/java

Now you will need to edit your shell configuration file, it should be .bashrc by default:

nano ~/.bashrc

Add the following lines to this config file:

PATH="$HOME/.bin/java/jdk-20.0.2/bin:$PATH"
export JAVA_HOME=$HOME/.bin/java/jdk-20.0.2

Press Ctrl-o to save the changes and Ctrl-x to exit the editor.

Now you need to source your shell configuration file:

source ~/.bashrc

Verify that you can run the Java VM by using the following command:

java --version

Now you can delete the file you downloaded and the unpacked folder:

rm jdk-20_linux-aarch64_bin.tar.gz
rm -rf jdk-20.0.2/