• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JAR file

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Given the following directory structure:



If the current directory is test, and you create a .jar file by invoking this,
jar -cf MyJar.jar myApp

then which path names will find a file in the .jar file? (Choose all that apply.)
A. Foo.java
B. Test.java
C. myApp/Foo.java
D. myApp/Bar.java
E. META-INF/Foo.java
F. META-INF/myApp/Foo.java
G. myApp/myAppSub/Bar.java

Answer:

C and G are correct. The files in a .jar file will exist within the same exact
structure in which they existed when the .jar was created. Although a .
a META-INF directory, none of your files will be in it. Finally, if any files
directory from which the jar command was invoked, they won’t be included
.jar file by default.

A, B, D, E, and F are incorrect based on the above. (Objective 7.5)


Hi everyone

I am studying chapter 10 of K&B SCJP studyguide and am struggling to understand the outcomes of the above code in question 10, selftest questions, a.jar file was created and they are asking which pathnames will find the file in the .jar file?
I suppose the jar command create a JAR file called MyJar.jar and it contain myApp diretory and myApp's entire subdirectory tree and files. If C is correct why D is incorrect and also i would like to understand why G is correct. Thanks in advance.



 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I suppose the jar command create a JAR file called MyJar.jar and it contain myApp diretory and myApp's entire subdirectory tree and files.


Did you try it out?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic