Java 包不在文件夹中
Java Package not in Folders
我有一个 java 程序,我通过 createGraphics()
从 BufferedImage
获取 Graphics2D
并将其打印出来并得到: sun.java2d.SunGraphics2D[font=java.awt........... you get the idea
但是当我转到我的 jdk 文件夹 sun
中没有名为 java2d
的文件夹 我在哪里可以找到它?
编辑
好的,我找到了 rt.jar
(谢谢@EmilyMabrey 和@f1sh),并尝试使用命令 jar xf rt.jar
提取它(在 Windows 10 上)但是看到了这个:
java.io.IOException: META-INF : could not create directory
at sun.tools.jar.Main.extractFile(Main.java:1050)
at sun.tools.jar.Main.extract(Main.java:981)
at sun.tools.jar.Main.run(Main.java:311)
at sun.tools.jar.Main.main(Main.java:1288)
看到这个other Stack Overflow Q/A about the runtime JAR (rt.jar or classes.jar depending on the OS you are using). This JAR is basically just like any other JAR you might write for a project, except instead of being a library or application, this JAR contains the classes used within and provided by the JVM itself. Packages define the folder structure of how compiled classes are stored within the JAR (they aren't filesystem folders), so you would have to look into the JAR itself to find the folder/package sun/java2d
. You can look at the files and the file structure of the JAR by following the instruction on how to unzip a JAR。
我有一个 java 程序,我通过 createGraphics()
从 BufferedImage
获取 Graphics2D
并将其打印出来并得到: sun.java2d.SunGraphics2D[font=java.awt........... you get the idea
但是当我转到我的 jdk 文件夹 sun
中没有名为 java2d
的文件夹 我在哪里可以找到它?
编辑
好的,我找到了 rt.jar
(谢谢@EmilyMabrey 和@f1sh),并尝试使用命令 jar xf rt.jar
提取它(在 Windows 10 上)但是看到了这个:
java.io.IOException: META-INF : could not create directory
at sun.tools.jar.Main.extractFile(Main.java:1050)
at sun.tools.jar.Main.extract(Main.java:981)
at sun.tools.jar.Main.run(Main.java:311)
at sun.tools.jar.Main.main(Main.java:1288)
看到这个other Stack Overflow Q/A about the runtime JAR (rt.jar or classes.jar depending on the OS you are using). This JAR is basically just like any other JAR you might write for a project, except instead of being a library or application, this JAR contains the classes used within and provided by the JVM itself. Packages define the folder structure of how compiled classes are stored within the JAR (they aren't filesystem folders), so you would have to look into the JAR itself to find the folder/package sun/java2d
. You can look at the files and the file structure of the JAR by following the instruction on how to unzip a JAR。