JAVA Environment Setup on Windows

I start to play antlr and before that I need to setup java environment on my windows box.

  1. Download JDK from orcale. The JDK package also includes JRE, thus there is no need to download JRE again.
  2. Install JDK(e.g. C:\Program Files\Java\jdk1.7.0_03) and setup JAVA_HOME, PATH, CLASSPATH environment variable
    • Add JAVA_HOME as “C:\Program Files\Java\jdk1.7.0_03″. JAVA_HOME represents the root directory of JDK. This serves two purposes:
      1. Other JAVA related paths are constructed relative to JAVA_HOME. Thus if SDK is upgraded, only JAVA_HOME needs to be changed.
      2. Some third party software assumes JAVA_HOME is properly setup.
    • Append %JAVA_HOME%\bin to PATH. So command like ” java”, “javac” can be run on command line without providing the absolute path. One interesting thing I notice is “java”, “javaw”, “javaws” are duplicated under C:\Windows\System32 which is already included in PATH. So really, even without doing this step, “java” can still be run without the absolute path.
    • Add CLASSPATH. First I create a folder at %JAVA_HOME%..\local\lib for putting any external java classes. In my case, I put “antlr-3.4-complete.jar” there. Thus my CLASSPATH is set to “.;antlr-3.4-complete.jar;” Notice the leading “.” which stands for the current directory.

That’s it. I haven’t done java since I left school. It’s a good exercise anyway. Antlr website also has a short guide on setting this up.

Subscribe to 天舟的云游格

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe