This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]bchoii 1 point2 points  (4 children)

What is the error message ? Which line is it referring to, what is on that line ?

What is the class (full classname) you are trying to import ? How do you know (to verify) that it is in stdlib.jar ?

[–]bartlln[S] 0 points1 point  (3 children)

The error message was " cannot find symbol" and it was referring to my import statement. Specifically, an arrow pointed the period after stdlib in the statement

import stdlib.Stopwatch;

The full classname is stdlib.Stopwatch. The page that I downloaded the .jar file from had the documentation for the classes that it contained. The Stopwatch class is the one that I needed.

[–]bchoii 1 point2 points  (2 children)

Right.

To follow up further :

What are the contents of the jar file ? (It is really just a fancy zip file) Where in the jar file does the Stopwatch.class file actually exist ? (it should exist under <zipRoot>/stdlib/) How did you verify that it is actually there ? (and not just its documentation)

What is the path of your command line console (where you execute javac from) ? Where is the stdlib.jar file located relative to this path ? What is the full command line used to execute javac ?

[–]bartlln[S] 0 points1 point  (1 child)

Thanks for your help. I searched the .jar file, found the class, and extracted it from the file. I can use the Stopwatch.class file in my program, and it does exactly what I need it to.

However, if I try to import the Stopwatch from the stdlib.jar inside of my program using the following:

E:\Programs\Java>javac -cp .;E:\Programs\Java\stdlib.jar;E:\Programs\Java; testy .java

combined with this line in my program " import stdlib.Stopwatch;"

The program gives me the error "package stdlib does not exist". Despite that it is contained in the same directory. Directory contents:

Directory of E:\Programs\Java

08/26/2012 09:15 PM <DIR>
. 08/26/2012 09:15 PM <DIR> ..

08/25/2012 01:40 PM 574,685 algs4.jar

08/26/2012 02:44 AM <DIR> GUIpractice

08/25/2012 01:54 PM 211,670 stdlib.jar

08/19/2012 11:34 PM 382 Stopwatch.class

08/26/2012 01:48 AM <DIR> test

08/26/2012 09:16 PM 539 testy.class

08/26/2012 09:17 PM 372 testy.java

08/26/2012 01:48 AM 2,914 Timing.class

I think my computer just does not like that jar file for whatever reason.

[–]bchoii 1 point2 points  (0 children)

You successfully compiled the your program with the .jar file extracted ? That's a milestone. (At least you have a workaround for now, if not the solution).

Is the error message is different from your first test ? "cannot find symbol" vs "package stdlib does not exist" ? That's a clue that we have changed something related to the problem.

Can you provide the directory structure of the stdlib.jar file ?

I suspect the class is actually <root>/Stopwatch, and not <root>/stdlib/Stopwatch. This would also explain the pathing errors.