No exception of type Exception can be thrown; an exception type must be a subclass of Throwable Exception.java

翻译:不能引发异常类型的异常;异常类型必须是throwable exception.java的字类.

package com.dream.Ex;
/*** * 2022年2月26日* @company* @author dream* @description 异常处理*/
public class Exception1 {public static void main(String[] args) {// TODO Auto-generated method stubdiv(10, 2);}/*** 除法运算*/private static void div(int num1,int num2){int arr[]= {1,2,3,4,5};try {int result=num1/num2;//alt+/System.out.println("result="+result);System.out.println(arr[1]);System.out.println(arr.length);}catch (ArithmeticException e) {System.out.println("除数不能为0!");}catch (ArrayIndexOutOfBoundsException e) {System.out.println("数组下标越界!");}catch(NullPointerException e) {System.out.println("空指针异常!");}catch(Exception e) {System.out.println("数据出现异常错误!");}System.out.println("程序结束!");}
}

中catch(Exception e)出现错误:No exception of type Exception can be thrown; an exception type must be a subclass of Throwable Exception.java

解决方法:将Eclipse中默认的Jre更换为你配置环境的JDK,再重新新建项目即可.
步骤照片如下:
Windows->Perferences->Java->Installed JRES->ADD->Standard VM->Next->Directory->jdk1.8.0_134(jdk版本)->选择文件夹->Apply->重新新建项目即可.



点击"Add"后,

点击"Next>"后:

点击Directory后:

选择JDK后,即可.
将JRE更换成JDK版本.

点击"Apply"即可.
在重新新建项目,再用

try{
//代码块即可
}
catch(Exception e){
//异常处理
}

就不会出现问题了 .

No exception of type Exception can be thrown相关推荐

  1. terminating with uncaught exception of type std::bad_cast: std::bad_cast

    terminating with uncaught exception of type std::bad_cast: std::bad_cast 我这里的情况: 我有两个so A 和B,调用程序c 把 ...

  2. Flutter-解决Try catch出现异常:type ‘_TypeError‘ is not a subtype of type ‘Exception‘ in type cast

    文章目录 出现场景 解决方案 分开处理(推荐) 判断类型 出现场景 使用Dio时,网络请求可能会出现异常,需要用try catch捕获. 捕获代码如下 try {var response = awai ...

  3. An unhandled exception of type 'System.IO.FileNotFoundException' occurred in Unknown Module

    今天编写一个c++ clr程序调用c# dll,由于不熟,爆出一个错误 An unhandled exception of type 'System.IO.FileNotFoundException' ...

  4. 【解决思路】HTTP Status 500 Type Exception ReportMessage Request processing failed; 【已解决】

    目录 零.前言 一.看错误提示 二.分析错误 三.定位问题 四.解决问题 Type Exception ReportMessage Request processing failed; nested ...

  5. java 判断exception类型_Checked Exception | Java语言设计者的失误?

    背景 最近公司一直在执行sonar扫描代码bug.漏洞及异味,但发现了很对异常处理的问题,大多数是对Java异常处理不正确导致的,那本文就谈谈Java的异常是什么?设计者的初衷又是什么? Except ...

  6. checked exception和unchecked exception区别

    http://blog.csdn.net/yuefengyuan/article/details/6204317 一. Java 中定义了两类异常: 1) Checked exception: 这类异 ...

  7. 记一次Jenkins 打包异常 ERROR: Exception when publishing, exception message [Failure]

    记一次Jenkins 打包异常 ERROR: Exception when publishing, exception message [Failure] 参考文章: (1)记一次Jenkins 打包 ...

  8. Jenkins发版常见问题:ERROR: Exception when publishing, exception message [Failure]

    Jenkins 报错日志: ERROR: Exception when publishing, exception message [Failure] Build step 'Send build a ...

  9. Checked exception及Unchecked exception对比

    一.异常分类 从异常处理机制的角度可以分为两类,Unchecked Exceptions和Checked Exceptions.Check即编译器检查程序是否已经抛出或处理了可能的异常.Uncheck ...

  10. ERROR: Exception when publishing, exception message

    jenkins出现ERROR: Exception when publishing, exception message ERROR: Exception when publishing, excep ...

最新文章

  1. 室内设计木地板材质合集包 Arroway – Design Craft Vol.4
  2. velocimeter-view android测速仪效果
  3. valgrind 看内存泄漏
  4. tar:file-changed-as-we-read-it报错处理
  5. 嵌入式系统的知识体系、学习误区及学习建议
  6. 关于SAP Spartacus ManageUnitsListComponent的一些试错
  7. 一款纯css3实现的超炫动画背画特效
  8. servlet中web.xml配置详解
  9. keepalived mysql双主架构图_基于MySQL双主的高可用解决方案理论及实践
  10. ajax加载时间长,如何最好地处理需要很长时间才能完成的ajax请求?
  11. CentOS中用yum安装Nginx
  12. C#socket编程序(二)
  13. 5. 公元二OO七年
  14. 使用visio画数据库模型图
  15. php ip 短时间 重复,记录服务器端ip,记录这个ip第一次启动文件的时间,并且排除重复的ip...
  16. 从零开始学人工智能--统计学习:统计学习基础知识
  17. 谷歌浏览器书签丢失,恢复工具
  18. 两万字长文:聊聊程序人生
  19. 使用Java程序实现计算器
  20. linux 蓝牙hci,实战Linux Bluetooth编程(三) HCI层编程

热门文章

  1. markdown颜色索引及表格背景颜色填充
  2. Why the MonthCalendar.MinDate is 01/01/1753?
  3. Python内进制转换(2进制,8进制,10进制,16进制转换)
  4. ❤️ Python 利用NetworkX绘制精美网络图 ❤️
  5. 史玉柱和他老同学的一段故事
  6. 从一个远程服务器的mysql数据库表的数据复制到本地电脑mysql数据库表,两张表结构一样就是复制数据...
  7. C盘空间不足,UE4的deriveddatacache目录位置修改
  8. [python][turtle]闪瞎眼的晶体管报时
  9. 牛顿法的收敛速度为何比梯度下降法快?
  10. 测试自动化风险或成功的条款