Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
589 views
in Technique[技术] by (71.8m points)

filesystems - My java program is throwing java.lang.ClassNotFoundException for some AWT classes what do I do?

when I ran the Java debugger, I found this "java.lang.ClassNotFoundException: sun/awt/resources/spi/awtProvider" and "java.io.FileNotFoundException: C:Program FilesAdoptOpenJDKjdk-11.0.6.10-hotspotconfaccessibility.properties (The system cannot find the file specified)" I think I know why, my data storage was running low so I moved my programs to a different drive, is that why it can't find java API classes? how do I fix this?

question from:https://stackoverflow.com/questions/65600876/my-java-program-is-throwing-java-lang-classnotfoundexception-for-some-awt-classe

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You don't need to fix this.

  • sun.awt.resources.spi.awtProvider is a class name that is automatically generated as a possible resource bundle provider. If the class is not found it will be ignored.

See the source at https://github.com/openjdk/jdk11u/blob/master/src/java.desktop/share/classes/java/awt/Toolkit.java#L1416:

            try {
                resources = ResourceBundle.getBundle("sun.awt.resources.awt");
            } catch (MissingResourceException e) {
                // No resource file; defaults will be used.
            }
  • accessibility.properties is an optional file that can be used to configure assistive technologies. If this file is not found nothing changes.

According to the sources at https://github.com/openjdk/jdk11u/blob/master/src/java.desktop/share/classes/java/awt/Toolkit.java#L423:

                try {
                    File propsFile = new File(
                        System.getProperty("java.home") + sep + "conf" +
                        sep + "accessibility.properties");
                    FileInputStream in =
                        new FileInputStream(propsFile);

                    // Inputstream has been buffered in Properties class
                    properties.load(in);
                    in.close();
                } catch (Exception e) {
                    // System-wide accessibility properties file does
                    // not exist;
                }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...