How to Set Up a Java Programming Environment

Method 1 of 2:

On Windows 8/10

  1. Install the JDK from the Oracle website.
    1. You can find the download here: http://www.oracle.com/technetwork/java/javase/downloads/index.html
    2. Make sure to download the JDK.
  2. Identify the installation location of the JDK.
    1. It is usually a sub-folder within this path: C:Program FilesJava
  3. How to Set Up a Java Programming Environment Picture 1
    Edit the System Environment Variables.
    1. On the window that appears, click the "Environment Variables..." button.
  4. Create a new variable named JAVA_HOME, and set the installation location of the JDK as the value.
  5. Edit the PATH variable.
    1. Add a semicolon at the end.
    2. Add the JDK installation location with "bin" after the semicolon.
  6. Make sure to click "Okay" on all of the Environment Variables to save the new settings.
  7. Open up Command Prompt.
    1. Hold Win+R to open the "Run..." dialog.
    2. Enter cmd and hit Enter.
  8. Verify the Java compiler is recognized.
    1. Type javac -version and hit Enter.
    2. If you see the version of Java printed out, it worked! If you see that it's "not recognized", go back and check the previous steps for any errors.
  9. Run a Java program.
    1. Copy the Hello World program from Oracle's website and save it to a file: https://docs.oracle.com/javase/tutorial/getStarted/cupojava/win32.html
    2. In Command Prompt, navigate to where to saved the file.
      1. If you're not comfortable with command prompt, there are many tutorials to help.[1] Check out How to Change Directories in Command Prompt.
    3. Run javac HelloWorld.java(assuming your file is named HelloWorld.java) to compile your Java source file into a class file.
      1. If you see an error, you likely have a bug in your program or haven't navigated to where your file is located.
    4. Run java HelloWorld to run your compiled Java program.
Method 2 of 2:

On a Mac

  1. Install the JDK from the Oracle website.
    1. You can find the download here: http://www.oracle.com/technetwork/java/javase/downloads/index.html
    2. Make sure to download the JDK.
  2. Open the Terminal.
  3. Verify the Java compiler is recognized.
    1. Type javac -version and hit Enter.
    2. If you see the version of Java printed out, it worked! If you see that it's "not recognized", go back and check the previous steps for any errors.
  4. Run a Java program.
    1. Copy the Hello World program from Oracle's website and save it to a file: https://docs.oracle.com/javase/tutorial/getStarted/cupojava/win32.html
    2. Navigate to where you saved the program.
      1. If you're not familiar with how to navigate in Terminal, there are many tutorials to help.[2][3][4]
    3. Run javac HelloWorld.java (assuming your file is named HelloWorld.java) to compile your Java source file into a class file.
      1. If you see an error, you likely have a bug in your program or haven't navigated to where your file is located.
    4. Run java HelloWorld to run your compiled Java program.
5 ★ | 1 Vote

May be interested

  • eQuiz - Multiple choice quiz about JAVAeQuiz - Multiple choice quiz about JAVA
    following are multiple-choice questions related to java programming language, there will be 23 questions in total with no answer for each time. let's get started!
  • How to Write Your First Program with JavaHow to Write Your First Program with Java
    java is an object-oriented programming language introduced by james gosling in 1995. that is, it represents concepts such as 'objects' and 'fields' (which are properties that describe objects). java is a 'write one place, run another' language: it is designed to run on any platform that has a java virtual machine (jvm). as a multilingual programming language, java is quite easy to learn and understand for beginners. this article is an initial introduction to java programming.
  • Basic Java exercises, with sample decodingBasic Java exercises, with sample decoding
    to serve your java learning needs, tipsmake.com has synthesized some java exercises from many sources, including sample code (for some articles). hopefully it can be helpful to learn your java programming language.
  • JAVA test test P1JAVA test test P1
    java is an object-oriented and class-based programming language. to help you read more interesting knowledge about the java programming language, the network administrator will send you a very interesting multiple choice question on this topic. please try.
  • What is the difference between Go and Java?What is the difference between Go and Java?
    is golang better than java? is golang harder than java? can golang replace java? this comparison will give you the answer.
  • Get familiar with NetBeans Java IDEGet familiar with NetBeans Java IDE
    in the following article, we will introduce you the most basic features of netbeans ide through a small test, which is to create the 'hello world' java application. and when finished, you will know the general knowledge and process when programming applications in ide ...
  • eQuiz - Multiple choice test on Java Swing Practice - Part 2eQuiz - Multiple choice test on Java Swing Practice - Part 2
    in the previous article, we introduced you to part 1 of the test of basic java swing knowledge. and below is part 2 of the quiz series with 14 questions, including some questions with many different answer options.
  • 9 things Java programmers should know in 2018 if they want a successful career9 things Java programmers should know in 2018 if they want a successful career
    you want to start the new year in a right direction? join tipsmake.com to consult 9 things java programmers should know in 2018 if you want a successful career!
  • What is JRE (Java Runtime Environment)?What is JRE (Java Runtime Environment)?
    jre (java runtime environment) is a software that runs on a computer operating system, providing the resources needed to run java programs.
  • JAVA P8 test quizJAVA P8 test quiz
    if you are interested in learning about the java programming language, the following quiz of network administrator will provide you with a lot of useful knowledge for your learning.