T*****e 发帖数: 361 | 1 代码如下:
import java.util.*;
public class test {
public static void main(String[] args) {
List list = new ArrayList( 100 );
for( int i = 0; i < 10; i ++ ){
list.add( i, String.valueOf( i*31 % 20 ) );
}
Collections.sort( list );
System.out.println( list );
}
}
编译错误:(jdk 1.5.0_01)
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Syntax error on token "<", invalid AssignmentOperator
Syntax error on token "=", != expected
Syntax |
m******t 发帖数: 2416 | 2
Are you sure you are running a 1.5 javac? From
the same command line where you got the error, run "javac -version".
【在 T*****e 的大作中提到】 : 代码如下: : import java.util.*; : public class test { : public static void main(String[] args) { : List list = new ArrayList( 100 ); : for( int i = 0; i < 10; i ++ ){ : list.add( i, String.valueOf( i*31 % 20 ) ); : } : Collections.sort( list ); : System.out.println( list );
|
T*****e 发帖数: 361 | 3 Yes, I am sure. I am using eclipse 3.0.2.
There is no other versions of java installed in my pc except jdk/jre 1.5.0_01.
【在 m******t 的大作中提到】 : : Are you sure you are running a 1.5 javac? From : the same command line where you got the error, run "javac -version".
|
T*****e 发帖数: 361 | 4 刚刚把jdk/jre1.5.0_01删除了,安装了jdk/jre1.5.0_02。
问题还是一样。
看了看eclipse/windows/preferences/java/installed jres,
只有我新安装的jdk1.5.0_02.
可是当我直接用命令行来编译运行这个class时都没有问题。
是不是eclipse并不是用jdk1.5.0_02在编译啊?
头疼……
【在 T*****e 的大作中提到】 : 代码如下: : import java.util.*; : public class test { : public static void main(String[] args) { : List list = new ArrayList( 100 ); : for( int i = 0; i < 10; i ++ ){ : list.add( i, String.valueOf( i*31 % 20 ) ); : } : Collections.sort( list ); : System.out.println( list );
|
u****s 发帖数: 2186 | 5 Eclipse 3.0.2 doesn't support JDK1.5, you need to install a plugin
or get 3.1M6
goto Project/Properties/Compliance
set the compile level to 1.5
【在 T*****e 的大作中提到】 : Yes, I am sure. I am using eclipse 3.0.2. : There is no other versions of java installed in my pc except jdk/jre 1.5.0_01.
|
T*****e 发帖数: 361 | 6 Thanks a lot. I got eclipse 3.1m6 and now the errors are gone. :)
【在 u****s 的大作中提到】 : Eclipse 3.0.2 doesn't support JDK1.5, you need to install a plugin : or get 3.1M6 : goto Project/Properties/Compliance : set the compile level to 1.5
|
T*****e 发帖数: 361 | 7 安装了eclipse 3.1m6,现在编译没有问题了。多谢!
对了,tomcat5.5.7没法编译generic code,有什么办法么?再谢!
1.5.0_01.
【在 u****s 的大作中提到】 : Eclipse 3.0.2 doesn't support JDK1.5, you need to install a plugin : or get 3.1M6 : goto Project/Properties/Compliance : set the compile level to 1.5
|