This is something that has always vexed me - the installation of .jar files and setting the classpath. (Not to mention JAVA_HOME, installing the JDK, JRE, etc, but that's another story)
I'm working through the tutorials -- 'scuse me, the "Cattle Drive" --. I'm up to Assignment OOP-1, wherein it tells me that I will need to get jr.jar into my classpath. According to the FAQ, it's quite alright if jr.jar is really jr.zip.
I've followed the directions in the FAQ. I've copied it to my "C:\Program Files\Java\jre1.5.0_03\lib\ext" folder, I've reset the classpath to point to where the .zip file is, I've unzipped the jr.zip file and THEN set the classpath for it's location. I still get "package com.javaranch.common does not exist.
I've fought with this same issue with other software packages. MANY times, and I don't know what's going wrong.
PLEASE, can SOMEONE explain it to me as if I were a six-year old?
Before you laugh at me too hard, remember, Albert Einstein said "If you can't explain something to a six-year-old, you don't understand it yourself."!
Given that jre is 'Java Runtime Environemt' and you need to have a jdk (Java Development Kit) installed to compile .java files, I'm guessing that you did everything right, except you put the jar in the wrong place relative to your javac.exe. (which I'll guess is in a folder named something like jdk1.5)
You don't need to put your custom jar files in the C:\Program Files\Java\jre1.5.0_03\lib\ext folder. In fact, I suggest that you DON'T do this. Instead, you should edit the system CLASSPATH variable to contain the JAR file itself. Note that the CLASSPATH must contain the JAR, not just the folder that contains the JAR. For example, if you have a JAR file named "myjar.jar" in a folder called "C:\myprogs", then your CLASSPATH should look like this:
I'm guessing that you have only tried to add the folder that contains the JAR and not the JAR file itself.
My only additional comment to Layne's description would be that if you already have a classpath set (and since you are reading the Cattle Drive instructions, I presume that you do), I would add the path to jr.jar to the the end of the existing classpath. So you might have CLASSPATH = .;C:\Java;C:\Java\jr.zip for example.
I would not recommend putting it in the JRE\lib\ext folder either. And you'll be better off if you delete all the unzipped class files before they begin to cause confusion (although you might possibly want to look at the source files at some point).
JavaBeginnersFaq "Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
You're right, I did have the CLASSPATH pointing to the folder, rather than to the .zip file. So, here's what I did: I removed the jr.zip file from the lib\ext folder, and pasted it to my c:\Program Files\Java folder. I did not unzip the file. I then changed the CLASSPATH to "c:\Program Files\Java\jr.zip". Just to be sure, I restarted my machine. I opened up BlueJ (My IDE of choice), wrote a stup program with a first line of "import com.javaranch.common.*; " and got the error message "package com.javaranch.common does not exist." Next, since BlueJ is on my E: drive, I copied the jr.zip file to "E:\BlueJ\lib", and edited the CLASSPATH to "c:\Program Files\Java\jr.zip; E:\BlueJ\lib\jr.zip. I rebooted the machine, tried to compile my stub program --- same error message. Finally I changed the CLASSPATH to "E:\BlueJ\lib\jr.zip", rebooted, recompiled, ... same thing.
I've always thought myself to be a reasonably intelligent person. What am I missing, here??
Generally, an IDE ignores the system CLASSPATH. It instead sets up its own. Now, I don't use BlueJ, so I can't tell you how to set the path therein, but generally it's under the settings for the project that you are working in. You might try looking at the docs for BlueJ on how to set the classpath.
Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.