[java] How to set JAVA_HOME in Linux for all users

It's Very easy to set a path in Linux. Do as follows :

Step-1 Open terminal and type sudo gedit .bashrc

Step-2 It will ask you your password. After typing the password ,it will open the bash file. Then go to end and type below

step-3

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

step-4 Then save the file and exit from file

Above is for a single user. For all users, you have to follow below steps

Step-1 gedit /etc/profile

Step-2 export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64/"

Step-3 export PATH=$PATH:$JAVA_HOME/bin

Hope this helps. Thanks!

Examples related to java

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How much should a function trust another function How to implement a simple scenario the OO way Two constructors How do I get some variable from another class in Java? this in equals method How to split a string in two and store it in a field How to do perspective fixing? String index out of range: 4 My eclipse won't open, i download the bundle pack it keeps saying error log

Examples related to linux

grep's at sign caught as whitespace How to prevent Google Colab from disconnecting? "E: Unable to locate package python-pip" on Ubuntu 18.04 How to upgrade Python version to 3.7? Install Qt on Ubuntu Get first line of a shell command's output Cannot connect to the Docker daemon at unix:/var/run/docker.sock. Is the docker daemon running? Run bash command on jenkins pipeline How to uninstall an older PHP version from centOS7 How to update-alternatives to Python 3 without breaking apt?

Examples related to java-home

Set ANDROID_HOME environment variable in mac Error: JAVA_HOME is not defined correctly executing maven How to set JAVA_HOME in Linux for all users Android Studio error: "Environment variable does not point to a valid JVM installation" Installing Android Studio, does not point to a valid JVM installation error How can I change Mac OS's default Java VM returned from /usr/libexec/java_home How to set JAVA_HOME path on Ubuntu? Where is the Java SDK folder in my computer? Ubuntu 12.04 How to set JAVA_HOME in Mac permanently? How to set CATALINA_HOME variable in windows 7?

Examples related to path-variables

How to set JAVA_HOME in Linux for all users Error in setting JAVA_HOME How to remove entry from $PATH on mac Is there an equivalent of 'which' on the Windows command line?