File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Cattle Drive and the fly likes catlle drive oop-1 to 4 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "catlle drive oop-1 to 4" Watch "catlle drive oop-1 to 4" New topic
Author

catlle drive oop-1 to 4

Benjoe Reyes
Ranch Hand

Joined: Apr 24, 2002
Posts: 109
i have downloaded JavaRanchCommon.zip and the direction says that i have to change the classpath to :
"C:\Java;C:\Java\JavaRanchCommon.zip" or to where i saved the zip file...
does the changing the classpath means the set path in autoexec.bat or on something else???
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9046
    
  10
PATH is different from CLASSPATH
Are you using Win9x?


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
juliane gross
Ranch Hand

Joined: May 30, 2002
Posts: 161
I use Win98 and put the JavaRanchCommon.zip in my autoexec.bat like this:
SET CLASSPATH=c:\jdk1.4\jul\JavaRanchCommon.zip;%CLASSPATH%
c:\jdk1.4\jul is where I do my assignments.
Hope it helps,
greetings
Juliane
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
You could probably do this in your autoexec.bat file. I'd guess that you've already solved the problem correctly. Does it seem to work? After starting your computer, from a command prompt, when you type SET CLASSPATH and press enter, what gets displayed?


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Benjoe Reyes
Ranch Hand

Joined: Apr 24, 2002
Posts: 109
i'm using '98...
typing set classpath at the command promt gets a syntax error...
however if juliane did it in autoexec and it works who am i to argue??? he he he... i'm going to do it once i get home...
thanks....
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9046
    
  10
Originally posted by Benjoe Reyes:
typing set classpath at the command promt gets a syntax error...

C:\>set classpath
should not give you a syntax error. You must have typed something wrong.

Hopefully you won't have any typo's in your classpath statement in your autoexec.bat file.
Benjoe Reyes
Ranch Hand

Joined: Apr 24, 2002
Posts: 109
thanks Marilyn
Benjoe Reyes
Ranch Hand

Joined: Apr 24, 2002
Posts: 109
i'm having problems with the common package zip file... i did the set classpath like what juliane did but not in the autoexec.bat. i made a bat file that when i run it sets the classpath :
SET CLASSPATH=C:\My Documents\Benjoe\Java\JavaRanch\JavaRanchCommon.zip;%CLASSPATH%
my DaysOld file is in:
C:\My Documents\Benjoe\Java\JavaRanch\JavaRanch Cattle Drive Codes\OOP-1 DaysOld\
my import statement is :
import com.javaranch.common.* ;
but when i compiled my code, to check what i did so far, i get the following errors:
> Executing: C:\PROGRAM FILES\CONTEXT\ConExec.exe "C:\j2sdk1.4.1_01\bin\javac.exe" "DaysOld.java"
DaysOld.java:1: package com.javaranch.common does not exist
import com.javaranch.common.* ;
^
DaysOld.java:15: cannot resolve symbol
symbol : class GDate
location: class DaysOld
GDate currentDate, birthDate;
^
DaysOld.java:18: cannot resolve symbol
symbol : class GDate
location: class DaysOld
currentDate = new GDate();
^
DaysOld.java:19: cannot resolve symbol
symbol : class GDate
location: class DaysOld
birthDate = new GDate( input );
^
4 errors
> Execution finished.
i'm using ConTEXT editor version 0.96.3
please help...
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9046
    
  10
SET CLASSPATH=C:\My Documents\Benjoe\Java\JavaRanch\JavaRanchCommon.zip;%CLASSPATH%
my DaysOld file is in:
C:\My Documents\Benjoe\Java\JavaRanch\JavaRanch Cattle Drive Codes\OOP-1 DaysOld\


It would be much simpler if you put the JavaRanchCommon.zip file in the same directory as your DaysOld file. Your classpath probably already includes
C:\My Documents\Benjoe\Java\JavaRanch\JavaRanch Cattle Drive Codes\OOP-1 DaysOld\
so you would add
C:\My Documents\...\OOP-1 DaysOld\JavaRanchCommon.zip
to it.
[ December 05, 2002: Message edited by: Marilyn de Queiroz ]
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1195
I typed set classpath at the command prompt, and I got the syntax error message. It looks like this:
C:\>set classpath
Syntax error
What's going on? My programs can find their classes, but I can't set my classpath.....
I still don't get classpath. I just don't get it. Every time I think I understand, someone asks a question like Benjoe's and I am confused all over again. I hate classpath. Is there any way to avoid having to deal with it? (Wah, wah, wah)
[ December 06, 2002: Message edited by: Carol Murphy ]
Benjoe Reyes
Ranch Hand

Joined: Apr 24, 2002
Posts: 109
the reason why i put the common package in a different directory is that i put each cattle drive codes in its own directory... if i put the common package in with DaysOld it would mean i should have a copy of commonpackage for every oop assignment that i have done... and set classpaths for everything...
the classpath was set just to JavaRanch not further down...
i have looked at the source code of the JDate and GDate hoping that i could just extract it and compile it in another package located in the jre/classes/ directory of the jdk, but the codes are, i think interconnected with all other codes in the common packages...
i might be forced to make my own solution based on the source codes( with the author's permission of course)... i'm logging to many downtime already... sorry...
to carol: sorry for the confusion but i think you made the same mistake i made, you typed set classpath in the command prompt without any path following it... dont' worry to err is human we have just to be thankful that there are people like those in JavaRanch that puts up with us... i've been in some other forums and wow!!! their heads are way up there!!!
by the way carol have you been doing oop1-4 already??? and you were able to use the common package without the set classpath thing??? how did you do it??? share the magic...
[ December 06, 2002: Message edited by: Benjoe Reyes ]
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
If SET CLASSPATH does not work, then what do you get when you type ECHO %CLASSPATH% at your DOS prompt???
BTW have you tried this in a normal DOS command window? I noticed an unfamiliar "conexec" up there,
and that seems to be some kind of command shell supplied with your fancy editor.
Try using "-verbose" as an option to javac to
findout what's happening.
Make sure you say "SET CLASSPATH=c:\whatever" and not "SET CLASSPATH = c:\whatever"; that is, no spaces!
-Barry
[ December 07, 2002: Message edited by: Barry Gaunt ]

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
If it's any help I have just done this on my Windows Me system:
Benjoe Reyes
Ranch Hand

Joined: Apr 24, 2002
Posts: 109
when i type echo %classpath% it prints out:
ECHO is on
conexec is sort of a command shell because i compile my codes thru the editor and not at the command prompt...
my set classpath has no spaces Barry but i'd look into your sample ASAP... i had to weed out a couple of things from it...
thanks...
Benjoe Reyes
Ranch Hand

Joined: Apr 24, 2002
Posts: 109
i already did oop-1 without the using JDate or GDate... i may hacve gone against instruiction and wasn't able to exercise reuse but it broaden my "working vocabulary"... i came to know GregorianCalendar. it even has a isLeapYear() method...
i weould stiil try to find out what's wrong with my using the common package even if in the end the problem points out to be moi...
Benjoe Reyes
Ranch Hand

Joined: Apr 24, 2002
Posts: 109
Originally posted by Benjoe Reyes:
i already did oop-1 without the using JDate or GDate... i may have gone against instructions and wasn't able to exercise reuse but it broaden my "working vocabulary"... i came to know GregorianCalendar. it even has a isLeapYear() method...
i would stiil try to find out what's wrong with my using the common package even if in the end the problem points out to be moi...
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
when i type echo %classpath% it prints out:
ECHO is on

That seems to imply the %classpath% is evaluating
to nothing. So CLASSPATH is not set.
What happens when you type "set" at the command prompt?
-Barry
Benjoe Reyes
Ranch Hand

Joined: Apr 24, 2002
Posts: 109
Barry, back to the first one:
echo %classpath% prints out :
c:/my documents/Java/JavaRanch/JavaRanchCommon.zip
but like i said when i import the XDate classes i get the errors...
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Back to basics (not BASIC)
Let's try the following...
1. create a directory on C: call it C:\JR
2. copy JavaRanchCommon.zip to it.
3. Put SET CLASSPATH=C:\JR\JavaRanchCommon.zip;. (notice the ;. !!!) in C:\AUTOEXEC.BAT
4. restart the machine
Then from a DOS window do
5. set ( check that CLASSPATH is correctly set up )
6. cd to your javaranch java files directory
7. javac <whatever-source-file>.java
I'm guessing, but it might just be that the directory "My Documents" with a space in it is fouling things up.
8. javac -classpath %CLASSPATH% <whatever-source-file>.java -- try this too
-Barry
[ December 08, 2002: Message edited by: Barry Gaunt ]
[ December 08, 2002: Message edited by: Barry Gaunt ]
Benjoe Reyes
Ranch Hand

Joined: Apr 24, 2002
Posts: 109
thanks barry... i'll let you know the outcome ASAP...
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9046
    
  10
Originally posted by Benjoe Reyes:
i did the set classpath like what juliane did but not in the autoexec.bat. i made a bat file that when i run it sets the classpath :

SET CLASSPATH=C:\My Documents\Benjoe\Java\JavaRanch\JavaRanchCommon.zip;%CLASSPATH%

> Executing: C:\PROGRAM FILES\CONTEXT\ConExec.exe "C:\j2sdk1.4.1_01\bin\javac.exe" "DaysOld.java"

i'm using ConTEXT editor version 0.96.3


  • Executing: C:\PROGRAM FILES\CONTEXT\ConExec.exe "C:\j2sdk1.4.1_01\bin\javac.exe" "DaysOld.java"I don't see anywhere in here where you are calling a bat file to set the CLASSPATH. I think setting it in the autoexec.bat file as an environment variable might be more practical.
  • Regarding the space in the classpath "My Documents"

  • One way around this is to use the shorter version of the subdir i.e.
    SET CLASSPATH=C:\MYDOCU~1>\Benjoe\Java\JavaRanch\JavaRanchCommon.zip;%CLASSPATH%
    Benjoe Reyes
    Ranch Hand

    Joined: Apr 24, 2002
    Posts: 109
    marilyn;
    i only call the bat file when i work on the oop project so the classpath is not set everytime i turn on the computer...
    i took note of you suggestions and shall implement it ASAP...
    thanks...
    Marilyn de Queiroz
    Sheriff

    Joined: Jul 22, 2000
    Posts: 9046
        
      10
    Executing: C:\PROGRAM FILES\CONTEXT\ConExec.exe "C:\j2sdk1.4.1_01\bin\javac.exe" "DaysOld.java"

    It would seem that if the bat file were being called, it would look more like
    <pre>C:\PROGRAM FILES\CONTEXT\ConExec.exe "C:\j2sdk1.4.1_01\bin\javac.exe -classpath C:\MYDOCU~1>\Benjoe\Java\JavaRanch\JavaRanchCommon.zip;%CLASSPATH%" "DaysOld.java"</pre>

    Or, if your bat file is calling javac,
    C:\PROGRAM FILES\CONTEXT\ConExec.exe daysOld.bat
    [ December 10, 2002: Message edited by: Marilyn de Queiroz ]
    Benjoe Reyes
    Ranch Hand

    Joined: Apr 24, 2002
    Posts: 109
    marilyn,
    the line: Executing: C:\PROGRAM FILES\CONTEXT\ConExec.exe "C:\j2sdk1.4.1_01\bin\javac.exe" "DaysOld.java" comes from the status/output of my ConTEXTeditor when i compiled the source code...
    i have already called my bat file to set classpath before i open my editor...
    Marilyn de Queiroz
    Sheriff

    Joined: Jul 22, 2000
    Posts: 9046
        
      10
    ok
    I suppose that you're aware that if you set the classpath in a DOS window that it is only valid in that DOS window. But if you set it when you start your editor, it should work just fine.
    [ December 11, 2002: Message edited by: Marilyn de Queiroz ]
    Benjoe Reyes
    Ranch Hand

    Joined: Apr 24, 2002
    Posts: 109
    Originally posted by Marilyn de Queiroz:
    [QB
    I suppose that you're aware that if you set the classpath in a DOS window that it is only valid in that DOS window. ][/QB]

    that got me thinking, i'm not aware of that... its a new one for me... my knowledge of dos commands dates back to pre Windows...
    thanks marilyn...
     
     
    subject: catlle drive oop-1 to 4