Is there a difference between a package and a folder in eclipse? for example, if I have this hierarchy requirement:
java –classpath C:\ChatCompany\BackendChatServer\
-Djava.security.policy=c:开发者_如何学C\HW2\permissions.policy
hw2.chat.backend.main.ChatBackendServer
when the package's name is:
hw2.chat.backend.main
, and "ChatCompany\BackendChatServer\
" is the folder name.
Then how can I make this separation between a package and a folder in eclipse, so that I can write:
package hw2.chat.backend.main;
, and not "package ChatCompany.BackendChatServer.hw2.chat.backend.main
"?
thanks
You need to:
- define your root project outside of the workspace. The root of the project (where the
.eclipse
and.classpath
are actually created) will be atC:\ChatCompany
for instance. - make
BackendChatServer
the source folder, under which all sub-directories likehw2
will be created as part of the package path of a Java class. - make the output of the compilation in the same directory than the sources.
That way:
- you can write "
package hw2.chat.backend.main
" - you can have a classpath set to "
C:\ChatCompany\BackendChatServer\
"
I found that when I create a project in eclipse I can add a source folder apart from the default "src", so I added this folder name: ChatCompany\BackendChatServer
, and then this line gets added to the .classpath file at the root of the project:
<classpathentry kind="src" path="ChatCompany/BackendChatServer"/>.
I suppose you can also add the folders manually outside eclipse, but then you have to change the .classpath yourself.
精彩评论