So I want to write java programs on Windows, besides writing codes, I have to be able to compile and test the programs, there are a few steps that need to be done before I could really do it without errors.
I needed Java SE Development Kit JDK 8, download and install. I use notepadd++ to write codes.
Now, Windows doesn’t know where javac or path of the program are, I have to set them or I’ll get all the errors. Using cmd windows and set the path. At the prompt:
set path=”C:\Program Files\Java\jdk1.8.0_20\bin”
set classpath=%classpath%;.; //don’t forget the little “.” between ;;
So, I used notepad++ to create a program call HelloWorld.java in my portable drive J:\java\programs\ with the content:
public class HelloWorld {
public static void main(String[] args) {
System.out.println(“Hello World.”);
}
}
Now I can compile the program with “javac HelloWorld.java”
Below is the screen shot of all the problems before I set the path of java and classpath.
Now the path is set temporarily, I need to set the path and classpath permanently so I don’t have to type every time.
Right-click mycomputer –>properties–>system protection–>advanced–>Environment Variables and add PATH and CLASSPATH with the java sdk bin address with “;”
Add PATH
Add CLASSPATH
No more setting PATH or CLASSPATH