Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
581 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 Answer

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;
                }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...