This week's book giveaway is in the Java in General forum.
We're giving away four copies of Helidon Revealed: A Practical Guide to Oracle’s Microservices Framework and have Michael Redlich on-line!
See this thread for details.
  • 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:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Package Statment for Directories with a period in the name

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have installed 1.4.2 on my machine. I have created a subdirectory called "work" to hold my work. The full path is c:\j2sdk1.4.2\bin\work. How do I specify that directory as a package name in my .java source files? Won't the periods in the directory c:\j2sdk1.4.2 create confusion in package statement? In the future, I plan to save my work to another directory that has no periods in the path name, away from the JDK directory, however, the question still remains. What do you think?
Thanks,
Tim
 
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Tim Moore:
Hi,
I have installed 1.4.2 on my machine. I have created a subdirectory called "work" to hold my work. The full path is c:\j2sdk1.4.2\bin\work. How do I specify that directory as a package name in my .java source files? Won't the periods in the directory c:\j2sdk1.4.2 create confusion in package statement? In the future, I plan to save my work to another directory that has no periods in the path name, away from the JDK directory, however, the question still remains. What do you think?
Thanks,
Tim


If you are just going to be doing 'work' on your own and everything is going to reside in this folder, then a better structure would be to make subdirectories under your work folder for each project you are doing.
EX: c:\j2sdk1.4.2\bin\work\proj1
Then when you want to use a class from another project, all you have to do is:
import projX.*;
or
import projX.ClassName;
This is a benefit from setting your classpath.
However, if you are going to be distributing your 'work' to other people, then consider setting up a structure such as:
These examples
 
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Won't the periods in the directory c:\j2sdk1.4.2 create confusion in package statement?


Yes, according to my simple experiment.

>javac sdk1.4\util\Test.java
sdk1.4\util\Test.java:1: ';' expected
package sdk1.4.util;
^
1 error
But you could solve this problem, by skipping the sdk1.4 directory in the package name and including sdk1.4 in the classpath:

>javac sdk1.4\util\Test.java
>java -classpath sdk1.4 util.Test
util.Test
[ July 09, 2003: Message edited by: Marlene Miller ]
 
Tim Moore
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, thanks for the input. It is appreciated.
Tim
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic