Alton Goodman wrote:
> 
> I'm attempting to learn java using the tutorial at java.sun.com.  My
> platform is Linux 2.0.30, a Slackware install.  I installed jdk1.1.6v4a
> per the instructions in the README file.  I haven't set the CLASSPATH
> env variable.
> 
> So I wrote a program Date.java and placed it in a package named
> packages.  packages is a subdirectory in my home directory.  Here is a
> snippet:
> package packages;
> 
> import java.lang.*;
> import java.util.StringTokenizer;
> 
> public class Date extends Object {
>   private int iMM = 1;
>   private int iYY = 1998;
>   private int iDD = 1;
>         .
>         .
>         .
>   public static void main( String[] args ) {
>     int i = 0;
>     Date[] d1 = {
>       new Date( 12, 9, 2010 ),
>       new Date( 0, 9, 2010 ),
>       new Date( 12, 0, 2010 ),
>       new Date( 12, 9, 0 ),
>       new Date( 2, 29, 2000 ),
>       new Date( 2, 29, 2001 ),
>       new Date( 2, 29, 2004 ),
>       new Date( 10, 7, 1998 ),
>       new Date( "February", 14, 1999 ),
>       new Date( "February", 29, 2000 ),
>       new Date( "February", 29, 2001 ),
>       new Date( "5/22/1972" ),
>       new Date( "2/29/1972" ),
>       new Date( "2/29/2000" ),
>       new Date( "2/29/1973" )
>     };
> }
> 
> I moved Date.class to ~/packages and rm'd Date.java and Date.class from
> the subdirectory that they had been created in.  Then I wrote
> Testdate.java to test Date.class :).  Testdata.java:
> import packages.Date;
> 
> public class Testdate {
>   public static void main( String[] args ) {
> 
>     Date d1 = new Date( 2 , 25, 2000 );
> 
>     System.out.println( d1.getDate() );
>   }
> }
> 
> BTW, Date.java does have a constructor and an accessor function.  I
> compile Testdate.java using:
> javac -classpath .:~/:/opt/jdk1.1.6v4a/lib/classes.zip Testdate.java
> 
> The compile executes without warnings or errors.  But when I attempt to
> run the app using:
> java -classpath .:~/:/opt/jdk1.1.6v4a/lib/classes.zip Testdate.class
> java complains that it cannot find Testdate.class.
> 
> Could someone help me?  I'm purposefully created a class that would have
> a name clash in attempting to learn packages.
> 
> Thanks in Advance,
> AlSTOP E-MAILING ME

Reply via email to