Most of the time as java developer, one of the first thing you do to set up on you new computer is java environment. This is basically telling your cmd (windows) terminal (mac or Linux) where to find the java.

java / javac (the compiler) is all under your java installation directory.

We assume that you have successfully downloaded and installed the JDK or JRE. If you are a developer we suggest you to download the latest JDK (Java Developer Kit).

Method 1
Method 1 of 2:

On Windows

  1. 1
    Click Start then right Click on "Computer" and choose "Properties."
  2. 2
    On the new window click "Advance system settings."
    Advertisement
  3. 3
    Choose "Environment Variables."
  4. 4
    Create variable with the following properties: name: JAVA_HOME , value: your path to jdk
  5. 5
    Update the PATH variable by appending %JAVA_HOME%\bin at the end
  6. 6
    Click the Save button
  7. 7
    Click Start > new > cmd
  8. 8
    When you type following you should see the newly installed java version
    • java -version
  9. Advertisement
Method 2
Method 2 of 2:

Linux

  1. 1
    in your .bashrc or .bash_profile file append following
    • export JAVA_HOME=<your-java-dir>
    • export PATH=$PATH:$JAVA_HOME/bin
  2. 2
    save the file
  3. 3
    in terminal type:
    • . .bash_profile or . .bashrc (note that you have a space) this tells your terminal to load the updated file in current terminal so you get the newly created java in your path
  4. 4
    You should see java version printed when you type following:
    • java -version
  5. Advertisement

About This Article

wikiHow is a “wiki,” similar to Wikipedia, which means that many of our articles are co-written by multiple authors. To create this article, 9 people, some anonymous, worked to edit and improve it over time. This article has been viewed 50,315 times.
How helpful is this?
Co-authors: 9
Updated: December 3, 2020
Views: 50,315
Categories: Java
Advertisement