Using an External Jar file

I was hoping my intro programming class would be easy, as I've done some C++ before, but go figure, it's not.

Although the language/concepts aren't to difficult to learn, it seems compiling programs is. For one program, I'm giving an external .jar file to use. I'm using crimson editor and I do have it setup with the jdk1.6.0. It compiles all my other programs besides this one (command line doesn't work either).

Essentially, I've created a project, I have an instantiable class, and an application class. I can call the instantiable class in the app class and creating/modifying objects works just fine. Then I have a .jar file added to the project that came from the class (supposed to be used for I/O, don't know why we can't just use the standard java classes, but oh well). anyways, when I try to call the methods in the .jar file I get the following error:

- Capture Output -

> "C:\Program Files\Java\jdk1.6.0\bin\javac.exe" file.java

file.java:6: cannot find symbol

symbol : variable externalJar

location: class file

int value = externalJar.getIntInput();

^

After doing some searching, I found that it might be due to the classpath. So I set the classpath to the directory.. no go. Then I set the classpath to the externalJar.jar file and I get the follow error:

- Capture Output -

> "C:\Program Files\Java\jdk1.6.0\bin\javac.exe" -classpath C:\folder\externalJar.jar file.java

error: error reading C:\folder\externalJar.jar; error in opening zip file

I'm at a loss. It works when I use Eclipse and I can just add the external jar file, but I don't want to use eclipse, it's slow and bulky. Any other solutions to this problem? Thanks.

E-Rod

*names were changed for a reason.. i already know i'm not misspelling anything

[1852 byte] By [e_roda] at [2007-11-26 18:04:02]
# 1

The error about not being able to find the variable externalJar has nothing

to do with the classpath. It's just that your code in file.java refers to this variable,

but you have not declared it anywhere.

Variables within a class, the names of classes and the names of .jar files

which contain packages have nothing whatsoever to do with one another.

If you are using a variable externalJar intending it to reference your external jar

file in some way, then your file.java code is seriously wrong.

(Also, classes and their associated source files should begin with an

uppercase letter.)

Regarding your attempt to specify the classpath when you invoke the

compiler (always a good idea), I think you should also include the current

directory (if that is where file.java is). Like this:"C:\Program Files\Java\jdk1.6.0\bin\javac.exe" -classpath C:\folder\externalJar.jar;. file.javaThe "error opening zip file" thing is odd. Make sure you are

able to read it (permissions OK, no other process has it locked). And that

it's not corrupt (Did you create it? If so, rebuild it. If not, aquire another copy.)

Sorry for the generalities and guesswork, but without seeing any code and

without knowing your directory structure or the contents of this externalJar.jar

it's hard to do any more.

pbrockway2a at 2007-7-9 5:34:20 > top of Java-index,Java Essentials,New To Java...
# 2

Well I do believe I'm accessing the .jar file correctly in my code, as we were given an example as to how to use it. Essentially, everything is in the same directory, so I don't even know why I should have to specify a classpath if all files are in the same folder. If i don't specify the classpath, I get the "cannot find symbol" error and if i specify the classpath to the .jar file and the current directory, I get the "cannot open zip file" error. I find this odd because I did redownload the .jar file, as the first time I wasn't able to open in with WinRar. But after I got a new copy of it, I was able to do so, and even extract the files. So why would I still get that error if I can open it with a normal zip utility? By the way, here's the code I'm using to access the .jar file. Again, this externalJar.jar file was given and and this is essentially the example as to how to use it. It works in Eclipse, but that's not right if it won't work even under the command line.

int value = externalJar.getInt();

Thanks.

e_roda at 2007-7-9 5:34:20 > top of Java-index,Java Essentials,New To Java...