I Got a source code which has a row: import ag.*; now I got a jar file(ag.jar) which should contain all the classes in ag-package. Tried to get them in the project through configure\options\jdkprofile\j2sdk1.4.03\edit->add archive->ag.jar from directory. Do I need the row import ag.*; still? I think i do not. When compiling, it gives a error message that package ar dosn't exist, which I think is correct. But still the compiler canot recognize the classes sopposedly under ag.jar. When I try to extract the files from ag.jar(to get the source code package) (jar xf ag.jar)I get error message java.lang.IllegalArgumentException at java.util.Zip.zip.ZipInputStream.getUTF8String, how should I interpret that? Does someone know how could i Examine what in jar-file? or alternatiely have I done something wrong in includin the ag.jar file, is there something else I shoul do there....? thanks for your time. Romulus
You still need the import statement. If you don't import the classes the compiler doesn't know where to find the classes you are using in your code. For example, if you had code like:
The compiler would throw an error because it doesn't know from what package to get the File class from. So you would need to adjust your code as:
Then the compiler says, oh, you are using File and it exists in the java.io package.
Joined: Jan 22, 2004
says still package ag doesn't exist, liked to see what's in the ag package, but it I try to examine it in command prompt with: jar tf ag.jar it gives error message like: META-INF/ META-INF/MANIFEST.MF java.lang.IllegalArgumentException at java.util.zip.ZipInputStream.getUTF8String(ZipInputStream.java:284) at java.util.zip.ZipInputStream.readLOC(ZipInputStream.java:237) at java.util.zip.ZipInputStream.getNextEntry(ZipInputStream.java:73) at sun.tools.jar.Main.list(Main.java:736) at sun.tools.jar.Main.run(Main.java:192) at sun.tools.jar.Main.main(Main.java:904) Still wondering why it does'n find ag package. Is it possible that there isn't package ag under ag.jar-file?