简体   繁体   English

eclipse无法导入java.util?

[英]eclipse can't import java.util?

I recently installed Eclipse 4.3 (Build id: 20130919-0819) onto my Windows 7 x64 machine and imported my old workspace, but all of them had some kind of strange problem (they had red exclamation marks on the project names instead of error x's). 我最近在Windows 7 x64计算机上安装了Eclipse 4.3(版本ID:20130919-0819)并导入了旧的工作区,但是它们都存在某种奇怪的问题(它们在项目名称上带有红色感叹号,而不是错误x)。 。 So I re-imported one, which got rid of the exclamation mark, but there is exactly one .java source file with errors now. 因此,我重新导入了一个摆脱了感叹号的文件,但是现在只有一个.java源文件存在错误。

It says it can't resolve "Import java.util", and of course everything using that also has an error too. 它说它无法解析“ Import java.util”,当然所有使用它的东西也都会出错。

What the heck? 有没有搞错? Isn't java.util one of the base libraries? java.util不是基本库之一吗? Also, I can't seem to find where to download/install packages. 另外,我似乎找不到在哪里下载/安装软件包。 Does eclipse have a separate program for that? Eclipse是否为此有单独的程序? I seem to remember using a package manager to install a few packages or SDKs or something back when I got eclipse on my Windows XP machine. 我似乎记得在Windows XP计算机上出现日食时使用软件包管理器来安装一些软件包或SDK或其他东西。

BTW yes I selected the x64 windows version, not the x86 one. 顺便说一句,我选择的是x64 Windows版本,而不是x86版本。 And if it matters at all, when I tried to unzip it with 7zip, it gave me many errors and wouldn't work, so I tried unzipping with the default windows zip thing and that seemed to work just fine. 而且,即使有什么关系,当我尝试使用7zip解压缩时,它给了我很多错误,并且无法正常工作,因此我尝试使用默认的Windows zip解压缩,这似乎很好。

import must be spelt with a lower-case "i". import必须使用小写的“ i”拼写。 Try this! 尝试这个!

...additionally, you might be wanting to say "import java.util.*;" ...此外,您可能想说“ import java.util。*;” because util is a package that contains many objects. 因为util是一个包含许多对象的软件包。 The * tells it to import all of those objects! *告诉它导入所有这些对象!

java.util is the collections framework package name. java.util是集合框架程序包名称。 you need to specify what classes you want to import so you can refer to them using there unqualified names, makes code more readable. 您需要指定要导入的类,以便可以使用那里的非限定名称来引用它们,从而使代码更具可读性。

if you want to import all classes in the package use import java.util.*; 如果要导入包中的所有类,请使用import java.util。*;。

if you need to add third party packages to your project, you can use a dependency management tool like maven and this can be easily integrated with eclipse. 如果需要在项目中添加第三方程序包,则可以使用诸如maven之类的依赖项管理工具,并且可以轻松地将其与eclipse集成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM