在java中,assert开关是jvm的选项,默认是关闭的,开启选项的参数为-enableassertions或者其简写-ea。如果需要在myeclipse或者eclipse调试时开启assert选项,需要对项目进行配置,这里介绍两种方法:

对于myeclipse,

首先,启动myeclipse,run->run configurations->java application ->选中要开启ea测试的程序

myeclipse和eclipse中开启java的assert选项

 

 

对于eclipse

1.Run -> Run Configurations->Java Application-> Arguments页签 -> VM arguments文本框中加上断言开启的标志:-enableassertions 或者-ea

 myeclipse和eclipse中开启java的assert选项
       2. Windows -> Preferences ->Java ->Installed JREs ->待使用的JDK ->Edit ->Default VM Arguments文本框中输入:-ea

myeclipse和eclipse中开启java的assert选项

 

 

参考:https://blog.csdn.net/styshoo/article/details/48209493

相关文章:

  • 2021-05-14
  • 2021-11-27
  • 2021-09-30
  • 2022-02-09
  • 2021-12-05
  • 2021-09-16
  • 2021-12-26
猜你喜欢
  • 2021-05-17
  • 2021-04-18
  • 2021-12-09
  • 2021-05-12
  • 2021-07-26
  • 2022-12-23
相关资源
相似解决方案