开发者

Java Importing Packages/.JAR

So, I was just wondering if there was anyway to import the entire Java Framework all at once without having to include the entire list at the header of my file. Or if there's a file I can write which compiles it all together.

Unless, this is "java.lang", perhaps? I doubt that's the universal though. I also would like to know the best method of importing the JDK framework (which I downloaded) into the E开发者_StackOverflow社区clipse IDE, if that's possible, and how it will pertain to my code.

I've been screwing with this for hours, now, and am confused -__-;

Thanks for any tips on this.


to import the entire Java Framework all at once without having to include the entire list at the header of my file.

No, you'll have to import each package you need separately. The most concise thing you can do is to use the * wild card, i.e., import java.util.*;

The reason is basically that your code would easily become ambiguous if you could import an entire API. Packages are a way of restricting name spaces. Importing them all together would sort of obstruct it's purpose.

I also would like to know the best method of importing the JDK framework (which I downloaded) into the Eclipse IDE

To include the jar-file in the project you right click on the jar-file and choose Add to build path.

If you want to import the classes used in your Java code automatically, you can do Source -> Organize Imports.


You can use a shortcut of * for package imports. For instance:

import java.util.*;

IDEs such as Eclipse make it easy to manage imports, however. In Eclipse, for instance, you can press ctrl+shift+O and it will search for any imports for you. (Or command+shift+O on the Mac.) Let the tools do the annoying work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜