Search code examples
jvmubuntu-20.04

JAVA_HOME not found in Ubuntu


Every time when I open the terminal in ubuntu and try sudo apt-get autoremove

can someone guide me on what to do?

Thanks

#The output will show this error

/usr/sbin/update-info-dir: 2: /etc/environment: JAVA_HOME: not found
dpkg: error processing package install-info (--configure):
 installed install-info package post-installation script subprocess returned error exit status 127
Errors were encountered while processing:
 install-info
E: Sub-process /usr/bin/dpkg returned an error code (1)

Currently my /etc/environment contains this informations

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/>
JAVA_HOME = /usr/lib/jvm/jdk-15

Solution

  • Basically, you have stuffed up the "/etc/environment" file:

    PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/>
    JAVA_HOME = /usr/lib/jvm/jdk-15
    

    The first line should not end with a > character. And there is a missing ". And it doesn't make sense for the root directory ( / ) to be on the search path.

    The second line should not have spaces before and after the =.

    However, I don't know exactly what the video tutorial was trying to tell you to do ... or why it even suggested that you should edit that file. (I certainly wouldn't mess with that file!!)

    My advice:

    1. Find and >>read<< a Linux tutorial (or book!) on how to use the shell. It will explain what environment variables, how they are set and how they are used. It will also explain what PATH is and what it should contain.

      I do NOT recommend watching videos. My observation is that they are too superficial and will often leave the viewer thinking that they understand, when they don't.

    2. Revert the "/etc/environment" file to what it was before you started.

    3. Either watch the video again and make the changes more carefully ... OR ... don't change it. If you don't change it you can put the environment variables into your shell startup script; e.g. "~/.bash_profile" if your shell is bash; see step 1!