Java – why is rt.jar not a classpath system attribute?

I use the system properties Java class. Path to find all jars and directories belonging to the classpath At the first sigth, this seems good But after careful observation, I found that when I used gradle to execute the program, there was no rt.jar.jar in this kind of path When executing 't.jar' from IntelliJ idea, it is part of this class

Why is the classpath between IntelliJ and gradle different in this way?

It should be clear that all classes contained in rt.jar can be loaded normally, which is just an attribute that puzzles me

Solution

Rt.jar does not need to be in the classpath because it is already in bootclasspath

You can refer to this Oracle doc: http://docs.oracle.com/javase/8/docs/technotes/tools/findingclasses.html

How does the Java launcher find the bootstrap class? The bootstrap class is a class that implements the Java 2 platform The bootstrap class is located in rt.jar and several other jar files in the JRE / lib directory These archives are specified by the value of the bootstrap classpath, which is stored in sun boot. class. Path is in the system attribute This system attribute is for reference only and should not be modified directly

You are unlikely to need to redefine the boot classpath The nonstandard option - xbootclasspath allows you to do this in those rare cicrcumstances that require different sets of core classes

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>