Share this page 

Use JDK1.5 new featuresTag(s): Environment

  • Download the JDK1.5 and install it.
  • From a shell, type
    > java -version
    The response should be something like
    java version "1.5.0-beta"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32c)
    On Windows, if you have a "file not found" message, it's because the JVM can't be found through the PATH. Do it again but with the complete path (if the path contains spaces, make sure to use quotes!) :
    > "c:\program files\java\j2sdk1.5.0\bin\java" -version
  • Let's do our first jdk1.5 program :
    public class Test15 {
      public static void main(String ... args) {
        System.out.printf("Local time: %tT", java.util.Calendar.getInstance());
  • Compile it (again you may need to specify the complete path to the compiler if the PATH is not set correctly):
    > "c:\program files\java\j2sdk1.5.0\bin\javac" -source 1.5
    Note the switch "-source 1.5", if you don't specify it you won't be able to access the new features (like System.out.printf()).
  • Run it
    >"C:\Program Files\Java\j2sdk1.5.0\bin\java" Test15
    Local time: 15:26:04