Search code examples
linuxubuntuvirtual-machinejava-home

I'm trying to set JAVA_HOME and path for JDK on Linux using .bashrc. But it says [ Error writing .bashrc: Permission denied ]. Why?


I'm trying to set JAVA_HOME and path for JDK on Linux using .bashrc (through this tutorial):

Step 1:

$ nano .bashrc

enter image description here

[Press Enter]

Step 2:

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export PATH=$JAVA_HOME/bin:$PATH

enter image description here

Step 3:

[Type Ctrl+x]

enter image description here

Step 4:

[Type Y]

enter image description here

Step 5:

[Type Enter] (According to this post)

enter image description here

As you can see, it is not allowing me to write .bashrc. What could I be doing wrong? I've researched similar errors but none have the same situation I am in. I would appreciate your experience and knowledge in this subject. Thanks!


Solution

  • You're trying to create a new file in the root directory /, where a normal user doesn't have permission to write. The file you must edit is located in your home directory, so open the editor this way: nano ~/.bashrc