*
The moose likes Cattle Drive and the fly likes Afraid of the next step....... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "Afraid of the next step......." Watch "Afraid of the next step......." New topic
Author

Afraid of the next step.......

Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1197
Okay, don't laugh at me, at least not until I get this up and running. I have just plucked up the courage to download the JavaRanchCommon.zip file from the link provided, and have placed a copy saved as JavaRanchCommon.jar in my C:\java folder. Do I have to unzip it manually, or will the compiler be able to extract the needed files from it as it is? I am venturing into completely unexplored territory here, and my anxiety level is through the ceiling! I have this terrible fear of doing something irreparable, and I have to get past this mental roadblock if I'm going to continue on to the OOP exercises. I am REALLY intimidated by this next step. Am I being ridiculous?
Johannes de Jong
tumbleweed
Bartender

Joined: Jan 27, 2001
Posts: 5089
The java compiler will look inside the *.zip file for the classes that you will use in these assignments.are
The zip file however, must be in the same directory your source is in or in a directory that is in your classpath.
You can however unzip the contents to see what is in the zip file and learn from Paul's code. No harm done if you do that
I personally found the OOP assignments difficult but very fulfilling.
Good luck.
[This message has been edited by Johannes de Jong (edited June 08, 2001).]
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1197
I have to run off to work now, so I will have to muster the courage to tackle this later. One thing is bugging me. I don't have access to Just Java 2, and I feel like I'm wandering around in the dark on this CLASSPATH thing. Where do I go to set my classpath? Can I just create a new folder in C:\java and place my source code and the *.jar file in there and compile it from there like I've done for all of the other assignments?
Johannes de Jong
tumbleweed
Bartender

Joined: Jan 27, 2001
Posts: 5089
I put my jar file in C:\java.
You dont need Just Java for the classpath thing. I'll find a good explanation later on and post it here ok.
Enjoy work, my weekend has already started
Ok Carol go look at this Using the JDK on a Windows System
The above tip I got from a posting by Steven YaegerII so all thanks to him if this tip helped

[This message has been edited by Johannes de Jong (edited June 08, 2001).]
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1197
Thanks for all your help Johannes. I looked up the info on the link you provided, and it answered some of my questions, but raised a few more! I don't have a classpath listed in my autoexec.bat file! This is what I have:
PATH=C:\java\bin
c:\PROGRAM~1\COMMON~1\NETWOR~1\VIRUSS~1\40~1.XX\scan.exe c:\
@IF ERRORLEVEL 1 PAUSE
That's it. No classpath. When I typed ECHO%classpath% at the dos prompt, I got this message:ECHO is on. Which doesn't tell me what my classpath is! So what do you think, I am worrying about nothing, or do I need to change something here before I proceed?
Johannes de Jong
tumbleweed
Bartender

Joined: Jan 27, 2001
Posts: 5089
To check your classpath simply type in set at the dos prompt.
All you have to do to add the classpath to your autoexec.bat is to add it by editing the autoxec.bat file. Its located in the root directory c:\.
type in the following :
set classpath=c:\java;.;.
Good luck.
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9050
    
  10
Originally posted by Carol Murphy:
I have just plucked up the courage to download the JavaRanchCommon.zip file from the link provided, and have placed a copy saved as JavaRanchCommon.jar in my C:\java folder.

Good so far.
Do I have to unzip it manually,
Not just to use it. You may unzip it if you want to read the source files, but you don't have to otherwise.

or will the compiler be able to extract the needed files from it as it is?
It will as long as you add it to your classpath.

I have this terrible fear of doing something irreparable
It's actually pretty hard to do something irreparable without knowing about it. Just don't reformat your hard drive. It is a real pain to rebuild everything that you have on there. Changing the CLASSPATH won't affect anything but running your java programs that you've written, and can always be changed again if you don't like the way it is.

Which OS are you using? Win9x or Win2000?

JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1197
I'm running Windows 98. There is no Classpath statement in my autoexec.bat file. Do I need to add one to do this next series of assignments? My compiler has worked fine so far without one.
Rick Fortier
Ranch Hand

Joined: Jun 04, 2001
Posts: 147
Originally posted by Carol Murphy:
I'm running Windows 98. There is no Classpath statement in my autoexec.bat file. Do I need to add one to do this next series of assignments? My compiler has worked fine so far without one.

Another alternative to the autoexec.bat is to create a batch file to do this. Sometimes this is helpful if you have multiple versions of the same project.
Johannes de Jong
tumbleweed
Bartender

Joined: Jan 27, 2001
Posts: 5089
Carol as far as I understand putting it in the same directory as your actual source (.java) file means you wont have to set it.
But setting it wont harm anything. So do it, even if only learning how to do it
Good luck.

[This message has been edited by Johannes de Jong (edited June 09, 2001).]
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1197
It has become obvious to me that there is a lot stuff about my computer that I don't understand because I never had to learn it in order to do what I wanted to do! I have to learn this stuff someday. Thanks for holding my hand!
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1197
I tried unzipping the .jar file in C:\java as well as the folder where I store my downloads before sending them off to their new homes. Neither file seemed to unzip or even open when I clicked on the icon. I then downloaded the file again and when prompted to unzip the file after the download was complete, did so. I got a beautiful display of unreadable characters! Here's an example:
L�0�"�E+�>&��Z+2��fD�Q/fq������O���k��1�xH��'T<"3�>)6?%�i
��gU�9�WPuc"��oRP�:���;��%R��3S�Vf42��Le|<�`S`���������������7���E������
What did I do wrong? Can't read this stuff!
[This message has been edited by Carol Murphy (edited June 09, 2001).]
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9050
    
  10
Did you unzip it with WinZip, pkzip, EazyZip, or some other program? What you have shown here looks like a compressed file, not the unzipped one. (You can download WinZip from http://www.download.com among other places and it is free for personal, class-type use.)

Regarding your CLASSPATH, it is best if you learn how to set it now, because in later assignments you'll need to modify it (again).
Johannes de Jong
tumbleweed
Bartender

Joined: Jan 27, 2001
Posts: 5089
Thats funny we had somone else complain as well that he could not read it.
see Jar
Especially Marily's questions posted June 08, 2001 03:36 PM.
I'll add another one to that, when did you download the jar file?
Oops cancel my question, way on top of this thread you say that you just downloaded it
[This message has been edited by Johannes de Jong (edited June 09, 2001).]
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9050
    
  10
Hmmm. I just downloaded and unzipped it. Worked fine for me.

By the way, when you looked at the unzipped file, did you look at one of the *.java files or did you look at a *.class file?

[This message has been edited by Marilyn deQueiroz (edited June 10, 2001).]
Johannes de Jong
tumbleweed
Bartender

Joined: Jan 27, 2001
Posts: 5089
Good one Marilyn, never though of that. I did the same a few days ago, looked in the .class file
Richard Boren
Ranch Hand

Joined: Mar 01, 2001
Posts: 233
After reading the JDK installation instructions and their recommendation for compiling and running java application involving user packages I created the following batch files for use with the JavaRanchCommon.zip file on Windows 98.
For compiling:
The %1 in the jc_JRanch.bat allows the source to be inputted into the batch; e.g.,
jc_JRanch DaysOld.java
where:
jc_JRanch is the batch file
%1=DaysOld.java
The source for jc_JRanch.bat:
REM Used for compiling applications using JavaRanchCommon.zip
javac -classpath c:\JRanch\JavaRanchCommon.zip;.; %1

For running:
The %1, %2, %3 and %4 allow the java class (%1) to be passed into the batch file along with up to 3 command args (%2, %3 & %4); e.g.,
jrun_JRanch DaysOld 04-16-1950
where:
jrun_JRanch is the batch file
%1=DaysOld; %2=04-16-1950; %3 & %4 are ignored.
The source for jrun_JRanch.bat:
REM Used for running applications using JavaRanchCommon.zip
java -classpath c:\JRanch\JavaRanchCommon.zip;.; %1 %2 %3 %4

If you use these batch files cut and past the batch file source into notepad, modify the classpath to where you placed the JavaRanchCommon.zip file and save using whatever name you want (I named mine jc_JRanch.bat and jrun_JRanch.bat) into the directory where you keep your source. Then to use you would enter the following at the prompt:
what_ever_you_named_your_batch_file_for_compiling DaysOld.java
and
what_ever_you_named_your_batch_file_for_running DaysOld yourBirthDate
Hope this is helpful and not too confusing.

[This message has been edited by Richard Boren (edited June 10, 2001).]
[This message has been edited by Richard Boren (edited June 10, 2001).]
[This message has been edited by Richard Boren (edited June 10, 2001).]
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1197
Thought I had Winzip installed already, but I couldn't find it, so I downloaded it and now it says I have to download JAVARANCHCOMMON.ZIP again because the entry point can't be found. The language might be wrong--- I'm late for work, did this on my lunch break! Will be back this evening!!!
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9050
    
  10
You shouldn't have to download the zip file again unless you've deleted it.
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1197
Dear Marilyn-
I tried to unzip the file again, and I got the same message, so I deleted the tainted file and downloaded it fresh. Guess what? It worked! The problem seems to be that I didn't have a program for unzipping files when I thought I did! Now I have a new folder on my C drive named unzipped which contains the source code for JAVARANCHCOMMON.zip! Whew! Am I relieved. And my computer didn't explode or anything!
Dear Richard-
I didn't understand much of what you were trying to tell me. I am practically computer illiterate except for the little bits of knowledge I have picked up in the last year. I will tackle your response in a little while when I find out what all those terms mean! (Sometimes you have to talk to me about this stuff as if you were talking to a 3rd grader!) Thanks for the post!
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1197
Okay everybody, now you can laugh! I think I'm over my classpath phobia! Thanks for your support!
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9050
    
  10
Originally posted by Richard Boren:
jc_JRanch DaysOld.java

The source for jc_JRanch.bat:
REM Used for compiling applications using JavaRanchCommon.zip
javac -classpath c:\JRanch\JavaRanchCommon.zip;.; %1

jrun_JRanch DaysOld 04-16-1950
The source for jrun_JRanch.bat:
REM Used for running applications using JavaRanchCommon.zip
java -classpath c:\JRanch\JavaRanchCommon.zip;.; %1 %2 %3 %4

That'll work, but it sure seems easier to me just to change the class path and type:
javac DaysOld.java
and
java DaysOld 1999-2-4

Richard Boren
Ranch Hand

Joined: Mar 01, 2001
Posts: 233
Marylin, this is from the installation instrcutions for SDK 1.3.1. with the important stuff in red:

Installation Notes
JavaTM 2 SDK, Standard Edition
Version 1.3.1
Microsoft Windows 95 / 98 / 2000 / ME / NT 4.0
.
.
.
5. Check the CLASSPATH variable
The CLASSPATH variable is one way to tell applications written in the Java programming language (including the Java 2 SDK utilities) where to look for user classes (classes that you develop). (The -classpath command-line switch is the preferred way.)
.
.
.

How do I modify the CLASSPATH?
Use the same procedure you used for the PATH variable in the previous step and either: a.Remove the CLASSPATH environment variable entirely.
With Java 2 SDK, the default value is ".", the current directory. To include any user classes, use the -classpath
command line switch instead with java, javac, javadoc and other tools. This is the recommended approach because it doesn't force one CLASSPATH for all applications.


There are two reason why I use the batch files: 1) from the Installation Notes (see quote above) it states the -classpath command-line switch is preferred and 2) at my work each time we reboot they over lay our profiles (has environment variables) with the companies defaults, so any changes made to path or classpath are overwritten when we reboot.
After reading the recommendations from the Installation instruction and having only the option of using -classpath at work I just decided to create the batch files and use them at both work and home.

That'll work, but it sure seems easier to me just to change the class path and type:
javac DaysOld.java
and
java DaysOld 1999-2-4
Originally posted by Marilyn deQueiroz

You could name the batch files jc.bat and jr.bat and just type:
jc DaysOld.java
and
jr DaysOld 1999-2-4

Unless you have some sort of restriction, like the one at my work, I feel it really is a preference issue.
Peter Gragert
Ranch Hand

Joined: Jan 16, 2001
Posts: 424
Another remark.
If you have "file.zip" You do not need winzip or other (direct) unzip programs. Your Java-destribution will (should) contain
jar.exe to do the same job and because one should master this tool earlier or later learn it now to use. Here the four most important commands:
First: jar -help
to get help from jar
Second: jar -vtf file.zip
To look at the (total) content of the archive
Third: jar -xtf file.zip
To extract all
Fourth: jar -cf yourname.jar jarfile1.class directory etc
To build a new archive.
Try it on a directory with some files and say one underdirectory
to see jar working!
It looks more difficult than it really is ;-)
Peter
Do it all in a 'command-window'
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1197
I'll give this another look when I've had some sleep! Thanks.
 
 
subject: Afraid of the next step.......