Why does IntelliJ import extra libraries from JDK

2019-08-06 14:59发布

问题:

I'm new to Java and IntelliJ and I am just doing a simple "hello world" program. IntelliJ has about 10+ libraries from JDK 1.6 added to my project even though I'm not importing anything in my classes that would seem to need them. I created a new project from scratch.

Some of the libraries are alt-rt.jar, charsets.jar, deploy.jar, dnsns.jar, javaws.jar, jce.jar, jsse.jar, localedata.jar, etc.

Can anyone explain why those libraries were added? Can I remove those libraries from the Module Settings/SDK with no ill effect?

回答1:

They will be in the classpath anyways as they are part of the standard library. I'm not sure what will happen if you remove them, but you definitely don't need to do that.



回答2:

These libraries aren't imported in your project, intelliJ has just parsed these jar to see what were the accessibles classes (for auto-completion) with the default classpath.

They won't be packaged with your project.

Plus as your JDK (or any SDK for what it worth) is defined for intelliJ and not for your project only, every project you will create in the future will use the already parsed data from your JDK.