• Post Reply Bookmark Topic Watch Topic
  • New Topic

Package Name  RSS feed

 
nirjari patel
Ranch Hand
Posts: 386
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am specifying package name as follows

1) package com.vanguard.iw.config.xml

How does it automatically resolve to a dir structure of "com\vanguard\iw\config\xml" ?

2) If I want to have a dir structure as "com.vanguard\iw\config\xml" , how can I get it ? As dir with "." will be resolved as a sub dir.

Thanks
 
Stefan Evans
Bartender
Posts: 1837
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
>How does it automatically resolve to a dir structure of "com\vanguard\iw\config\xml" ?

While it isn't part of the java language spec, it is just 'the way things work' in java
http://docs.oracle.com/javase/tutorial/java/package/managingfiles.html

>If I want to have a dir structure as "com.vanguard\iw\config\xml" , how can I get it ? As dir with "." will be resolved as a sub dir.
I know of no way to do this.
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nirjari patel wrote:If I want to have a dir structure as "com.vanguard\iw\config\xml" , how can I get it ?

To what end are you doing this? Seems like a pointless exercise to me, honestly. The way Java works is fine; it's best to just go with the flow rather than try to force your will. It has worked for countless number of applications and developers, why shouldn't it work for you? Designing the rest of your program should be challenging enough for your creativity without trying to fight the way Java expects packages to be structured as a hierarchy of directories in the file system.
 
nirjari patel
Ranch Hand
Posts: 386
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its nit a matter of use case. I am trying to understand this, as I am confused on this part.

I have seen same thing, while creating dir structure in eclipse. When I create a dir as com.vanguard.iw.config.xml , it would create a tree structure in eclipse as com\vanguard\iw\config\xml , but in one onstance I got dir as com.vanguard.iw.config.xml. Since then this question is in my mind.

please clarify this point for eclipse that how does com.vanguard.iw.config.xml recolve to dir structure and does not create one dir by the name "com.vanguard.iw.config.xml" ? When I create a dir on desktop and name it as "com.vanguard.iw.config.xml", it stays as name of that dir and does not resolve to tree structure. So, why , while creating dir in eclipse , that rule is not applicable ?
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because Eclipse is smart enough to understand that if you want to create a directory for the package "com.vanguard.iw.config.xml", you actually want a structure of nested directories ""com\vanguard\iw\config\xml".

Windows Explorer obviously doesn't know anything about Java, so if you create a directory named "com.vanguard.iw.config.xml" in Windows Explorer, then that's exactly what you'll get - a directory named "com.vanguard.iw.config.xml", and not a hierarchy of directories.
 
Dave Tolls
Ranch Foreman
Posts: 3068
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nirjari patel wrote:I have seen same thing, while creating dir structure in eclipse. When I create a dir as com.vanguard.iw.config.xml , it would create a tree structure in eclipse as com\vanguard\iw\config\xml , but in one onstance I got dir as com.vanguard.iw.config.xml. Since then this question is in my mind.



Look in your source directory under your Eclipse project where you think it has created a directory structure with '.' and you'll see it hasn't.
Eclipse has a file view (or something like that) which shows the directory structure and a project view which shows the logical structure of your project.
 
nirjari patel
Ranch Hand
Posts: 386
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks everyone.

I have not checked the behavior. But I believe it works the way, you guys explained. That clears my confusion.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!