依次进入在MyEclipse8的菜单项Window -> Preferences -> Java -> Compiler -> Compliance and Classfiles
断言在java的JDK1.4版本中添加进来,JVM默认assertion的功能是关闭的.
这个设置告诉编译器识别和允许断言语句,但是还没有开启断言。
接下来,进入菜单项Window -> Preferences -> Java -> Compiler -> Compliance and Classfiles,并且设置:
Compiler Compliance Level: 1.6
Use default compliance settings: unchecked
Generated .class files compatibility: 1.6
Source compatibility: 1.6
Generated .class files compatibility: 1.6
Source compatibility: 1.6
Disallow identifiers called 'assert': Error
最后在Run -> Run... -> Arguments菜单项的VM arguments区域,加上断言开启的标志
-enableassertions 或者
-ea 就可以了
本文介绍如何在MyEclipse 8中设置Java编译器以启用断言功能。首先需要调整编译器合规级别至1.6,并确保源代码兼容性同样设置为1.6。接着,在运行配置中加入-ean参数来激活断言。
1752

被折叠的 条评论
为什么被折叠?



