SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
do not anger the GODS.
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
SCJP 1.5 94%.
The greatest glory in living lies not in never falling, but in rising every time we fall.
Originally posted by Ankit Garg:
I feel that the second command should be
java -classpath .;MyJar.jar GetJar
The future belongs to those who believe in the beauty of their dreams.Dream BIG!
J C upadhyay wrote:I think the answer is correct. Suppose if MyJar.jar file was not created then as per question
test-|
|-GetJar.java
|
|-myApp-|
|-Foo.java
the program compiles and runs using the command:
test>javac GetJar.java
test>java GetJar
I think this is because the root directory of package myApp is test. As we are running the program from test , the compiler searches the subdirectory and finds the Foo.java file. Similarly, the JVM can also find the file.
So, when we make the myJar.jar file using:
test>jar -cf MyJar.jar myApp
and compile using:
test>javac -cp MyJar.jar GetJar.java
However, to run either of the following commands work:
1. java GetJAr
2.java -cp MyJar.jar:. GetJar
J C upadhyay wrote:
J C upadhyay wrote:I think the answer is correct. Suppose if MyJar.jar file was not created then as per question
test-|
|-GetJar.java
|
|-myApp-|
|-Foo.java
the program compiles and runs using the command:
test>javac GetJar.java
test>java GetJar
I think this is because the root directory of package myApp is test. As we are running the program from test , the compiler searches the subdirectory and finds the Foo.java file. Similarly, the JVM can also find the file.
So, when we make the myJar.jar file using:
test>jar -cf MyJar.jar myApp
and compile using:
test>javac -cp MyJar.jar GetJar.java
However, to run either of the following commands work:
1. java GetJAr
2.java -cp MyJar.jar:. GetJar
Bras cause cancer. And tiny ads:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|