I'm trying to set my java environment variable but I am new to Ubuntu so don't know how to update it through Vi. I want to do the following things:
Edit the environment file
# vi /etc/environment
Update the existing
PATHvariable by adding the below
binfolders, separated with a colon
HOMEdirectory paths can be different based on version and update,here the version is
1.8and the update is
151. Add the below variables at the end of environment file, making changes for your specific version and update.
J2SDKDIR="/usr/lib/jvm/jdk1.8.0_151" J2REDIR="/usr/lib/jvm/jdk1.8.0_151/jre" JAVA_HOME="/usr/lib/jvm/jdk1.8.0_151" DERBY_HOME="/usr/lib/jvm/jdk1.8.0_151/db"
environmentfile should now be similar to this text:
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/jdk1.8.0_151/bin:/usr/lib/jvm/jdk1.8.0_151/db/bin:/usr/lib/jvm/jdk1.8.0_151/jre/bin" J2SDKDIR="/usr/lib/jvm/jdk1.8.0_151" J2REDIR="/usr/lib/jvm/jdk1.8.0_151/jre* JAVA_HOME="/usr/lib/jvm/jdk1.8.0_151" DERBY_HOME="/usr/lib/jvm/jdk1.8.0_151/db"
My problem is I don't know much about editing and saving in Vi; I tried to do it through some resources but then it start giving warning and I don't want to corrupt things so I thought I should ask for help from some experienced users, so kindly help me through guiding step by step on how to do above things in Vi through terminal. I am using Ubuntu 16.04 LTS. Thank you!
sudo nanoif you know nano. To edit and save a file using Vi(m), see How do I save files edited with vim?
sudo nanoit was quiet easy :)