Eclipse (Java) -在创建一个新包之后,我无法向它添加源文件

时间:2023-01-18 23:16:19

I have a Java project open in Eclipse with a bunch of source files under the (default package). I created a new package in the project that I wanted to move all my source files into, but when I attempt to move them, nothing happens. The little package symbol for my new package is also white, unlike the usual brown package symbol. Anyone have any idea what's going on and how I can fix this?

我在Eclipse中打开了一个Java项目,在(默认包)下有一堆源文件。我在项目中创建了一个新的包,我想把所有的源文件都移动到其中,但是当我试图移动它们时,什么都没有发生。我新包装的小包装符号也是白色的,不像通常的棕色包装符号。谁知道发生了什么事,我该怎么解决?

Also, I just wanted to make sure that once I get this working I don't have to actually move my source files to any new folders (as in, where the actual files are stored in the OS). All I have to do is put them into the package inside Eclipse, but the actual files can stay where they are in the OS file system, right?

另外,我只是想确保,一旦我完成这个操作,我就不需要将源文件移动到任何新的文件夹(比如,实际文件存储在操作系统中)。我所要做的就是将它们放入Eclipse中的包中,但是实际的文件可以保留在OS文件系统中的位置,对吗?

EDIT: Figured out that the source of the problem is that I only made references to my source files in Eclipse, and didn't actually copy them into it.

编辑:发现问题的根源是我只在Eclipse中引用了源文件,实际上并没有将它们复制到其中。

2 个解决方案

#1


1  

Since you have linked it from an external source, obviously you cannot move them around as it is going to reflect the package structure as the files reside on the disk. A quick way would be to move the files on the disk itself where the files reside, and refresh your java project. NOTE: you may have to change the package names manually after you have done this.

由于您已经从外部源链接了它,显然您不能移动它们,因为它将反映包结构,因为文件驻留在磁盘上。一种快速的方法是将文件放在文件所在的磁盘上,并刷新您的java项目。注意:完成此操作之后,您可能需要手动更改包名。

#2


0  

Right click the class, move down to refractor and click on move. From there just click on the target package, and it should be moved.

右击类,向下移动到折射层,然后点击移动。从那里只需单击目标包,它就应该被移动。

#1


1  

Since you have linked it from an external source, obviously you cannot move them around as it is going to reflect the package structure as the files reside on the disk. A quick way would be to move the files on the disk itself where the files reside, and refresh your java project. NOTE: you may have to change the package names manually after you have done this.

由于您已经从外部源链接了它,显然您不能移动它们,因为它将反映包结构,因为文件驻留在磁盘上。一种快速的方法是将文件放在文件所在的磁盘上,并刷新您的java项目。注意:完成此操作之后,您可能需要手动更改包名。

#2


0  

Right click the class, move down to refractor and click on move. From there just click on the target package, and it should be moved.

右击类,向下移动到折射层,然后点击移动。从那里只需单击目标包,它就应该被移动。