调试过程中发现按f5无法走进jdk源码

时间:2022-04-26 00:48:55

debug 模式 ,在fis=new FileInputStream(file); 行打断点 调试过程中发现按f5无法走进jdk源码

package com.lzl.spring.test;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream; import org.junit.Test; public class Test1 { private static String name="C:\\Study\\2401.jpg_wh1200.jpg"; public static void inputStream() {
try {
InputStream a=new FileInputStream(name);
} catch (FileNotFoundException e) {
String message = e.getMessage();
System.out.println(message);
e.printStackTrace();
}
} @Test
public void test11() {
// inputStream();
Person per=new Student("haha");
per.doSomething();
}
public static void main(String[] args) { FileInputStream fis=null;
try {
File file=new File(name);
fis=new FileInputStream(file);
int available = fis.available();
System.out.println(available);
long n=500000;
fis.skip(n);
int available2 = fis.available();
System.out.println("available2 is "+available2 ); } catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
}finally {
if(fis!= null) {
try {
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}

经查阅资料发现:
eclipse默认是使用的java环境是JRE(Java Runtime Environment 即java运行时环境)环境,jre环境是不支持调试的;需要将eclipse的环境换成JDK的。查看eclipse运行环境方法如下: window  -->  preference  -->  java  -->  Installed JREs --> 右侧 会看到 eclipse的java环境了。
既然JRE不允许调试那就将eclipse的环境换成jdk的配置如下:

第一步找到 Installed JREs环境配置

调试过程中发现按f5无法走进jdk源码

第二步:将要调试的工程的引用的环境换成jdk的(即  Buil Path)如图:

调试过程中发现按f5无法走进jdk源码

调试过程中发现按f5无法走进jdk源码

现在可以进行jdk源码的调试和跟踪了