I’m trying to compile the following java app: http://blogs.oracle.com/andreas/resource/InstallCert.java (as outlined here, but I get a few errors:
C:\foo>javac InstallCert.java
InstallCert.java:122: ';' expected
for (int b : bytes) {
^
InstallCert.java:129: illegal start of expression
}
^
2 errors
I am using version jdk 1.4.2_11
The first problem is that your java compiler does not recognize the class
StringBuilder. Since it is in thejava.langpackage which does not need to be imported, the only explanation is that your JDK is Java 1.4 or older, sinceStringBuilderwas only introduced in Java 1.5So you need to update your Java installation (or if you have multiple JDKs installed, make sure you use the right one).
Update:
The new error is also caused by the old Java version, because the for-each loop syntax was only added in Java 1.5 as well. Update your JDK already. 1.4 is really, really old and should not be used anymore.