SCJP 6.0 (88%)
second one "javac GetJar" I think will give an error as the classpath doesn't contain " . "
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Dragos Nica wrote:
Now, in the book A) is checked as a correct answer, but I don't find the logic.
I agree that javac will run withot errors but the second one "javac GetJar" I think will give an error as the classpath doesn't contain " . " and java will not find a GetJar class file .
Any suggestion?
SCJP 5.0 SCWCD 5.0
Ankit Garg wrote:This is an error in the book, it has been discussed many times like here.
[Edit: misread the question]
second one "javac GetJar" I think will give an error as the classpath doesn't contain " . "
I think you want to say "java GetJar". There's no problem with this as if you don't set the classpath, then javac and java commands automatically look into the current directory...
SCJP 6.0 (88%)
SCJP 5.0 SCWCD 5.0
first thing : you are compiling the java file right?? in other words you are generating a class file for the corresponding java file.
here you are compiling a java file which is inside a jar file .
just answer two questions :
so what will happen when the java file will be compiled ?
where will the generated class file go?? check it out and you will get to know why the second command is correct.
avi sinha
SCJP 6.0 (88%)
avi sinha wrote:after compiling just check whether a class file is there in the current directory or not??
avi sinha
SCJP 6.0 (88%)
SCJP 6.0 (88%)
Dragos Nica wrote:
Ok ... I got it.
The class file Foo.class was missing in my tar file. I rebuild the tar file and is working now.
Thank you all.
SCJP 6.0 (88%)
In my point of view this set of commands will only work if "Foo.class" is located in myApp subdirectory and not in MyJar.jar
If "Foo.class" is located only in jar file , then i should specify" java -classpath MyJar.jar GetJar "
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
SCJP 6.0 (88%)
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Ankit Garg wrote:The question doesn't says that there's Foo.class outside of the JAR file, that's why it is required to include the jar file in the classpath for the program to run properly. As I said earlier, this is an error in the book...
SCJP 6.0 (88%)
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |