I'm having issue when i run my java application on a Sco OpenServer Release 5.0.6
My Sco OpenServer Release 5.0.6 have a java version which is :
# java -version
java version "1.3.1_22"
Java(Tm) Runtime Environment, Standard Edit开发者_JAVA百科ion (build SCO-UNIX-J2SE-1.3.1_22:* FCS*:20080305) Classic VM (build SCO-UNIX-J2SE-1.3.1_22:FCS:20080305, green threads, sunwjit)
My java application have developed in Windows with java version 6 update 25.
i understand , i should change my code to work with java 1.3 like following trouble :
- Generic is not supported like
ArrayList<String>
- String.format is not supported for
(String,double)
- For each loop is not supported
What code should come to replace the unsupported java version code below?
ArrayList<String> messages;
for (String message : messages)
String.format("%1$td/%1$tm/%1$tY %1$tI:%1$tM:%1$tS %1$Tp", new Date())
Is there no possibility to upgrade the version of Java on your server? 1.3 is pretty ancient and I think you'll end up with trouble. But to answer your specific questions:
/* ArrayList<String> messages; */
ArrayList messages;
/* for (String message : messages) */
for (Iterator it = messages.iterator(); ; it.hasNext()) {
String message = it.next();
...
}
/* String.format("%1$td/%1$tm/%1$tY %1$tI:%1$tM:%1$tS %1$Tp", new Date()) */
new SimpleDateFormat("your-desired-format").format(new Date());
for(int i=0;i<messages.size();i++) {
String s = messages.get(i).toString();
}
精彩评论