Use JDK1.5 new featuresTag(s): Environment
- Download the JDK1.5 and install it.
- From a shell, type
The response should be something like
> java -version
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!) :java version "1.5.0-beta" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32c) JAVA HOTSPOT(TM) CLIENT VM (BUILD 1.5.0-BETA-B32C, MIXED MODE)
> "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):
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()).
> "c:\program files\java\j2sdk1.5.0\bin\javac" -source 1.5 Test15.java
- Run it
>"C:\Program Files\Java\j2sdk1.5.0\bin\java" Test15 Local time: 15:26:04
mail_outline
Send comment, question or suggestion to howto@rgagnon.com
Send comment, question or suggestion to howto@rgagnon.com