my dog learned polymorphism*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Package Statment for Directories with a period in the name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Package Statment for Directories with a period in the name" Watch "Package Statment for Directories with a period in the name" New topic
Author

Package Statment for Directories with a period in the name

Tim Moore
Greenhorn

Joined: Jul 07, 2003
Posts: 17
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
leo donahue
Ranch Hand

Joined: Apr 17, 2003
Posts: 327
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


Thanks, leo
Marlene Miller
Ranch Hand

Joined: Mar 05, 2003
Posts: 1391
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

Joined: Jul 07, 2003
Posts: 17
Ok, thanks for the input. It is appreciated.
Tim
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Package Statment for Directories with a period in the name
 
Similar Threads
Importing Packages & Classpath
Setting up Paths Permanently
urgent help in running examples from hf jsp servlets
tomcat path issues
Problem compiling pgm