• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Package Name

 
Ranch Hand
Posts: 386
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 17734
302
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic