This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes question reg jar file Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "question reg jar file" Watch "question reg jar file" New topic
Author

question reg jar file

ujjawal rohra
Ranch Hand

Joined: Mar 20, 2010
Posts: 101
Suppose ther is a file A.java which needs access to a file D.java located in file myjar.jar.
The directory structure in myjar.jar is B/C/D.java.
Then when using classpath i will have to state only the name of jar file or will i have to specify the directory structure also ??
such as myjar.jar/B/C


SCJP 6
Rajeev Rnair
Ranch Hand

Joined: Mar 22, 2010
Posts: 308

ujjawal rohra wrote:Suppose ther is a file A.java which needs access to a file D.java located in file myjar.jar.
The directory structure in myjar.jar is B/C/D.java.
Then when using classpath i will have to state only the name of jar file or will i have to specify the directory structure also ??
such as myjar.jar/B/C


I believe the file D.java is in a "package B.C"
and you do "import B.C.D" in "A.java"
Assuming current dir is having myjar.jar and A.java

you have to use


SCJP6, SCWCD5, OCP-JBCD5, OCE-JWSD6 OCE-JPAD6 , OCM-JEA5 1,OCM-JEA5 2,3 - Brainbench certifications: J2EE, Java2, Java2-NonGUI, JSP, SQL2000 Admin, SQL2000 Programming , Brainbench certified Java Programmer, Computer Programmer, Web Developer, Database Administrator
ujjawal rohra
Ranch Hand

Joined: Mar 20, 2010
Posts: 101
But if B/C represents a directory structure and not a package then what will be the command???
ujjawal rohra
Ranch Hand

Joined: Mar 20, 2010
Posts: 101
Somebody please answer
ujjawal rohra
Ranch Hand

Joined: Mar 20, 2010
Posts: 101
Some body answer....
I am waiting
Rajeev Rnair
Ranch Hand

Joined: Mar 22, 2010
Posts: 308

ujjawal rohra wrote:Suppose ther is a file A.java which needs access to a file D.java located in file myjar.jar.
The directory structure in myjar.jar is B/C/D.java.
Then when using classpath i will have to state only the name of jar file or will i have to specify the directory structure also ??
such as myjar.jar/B/C


Couple of things here:
1. For your A.java to run, you should have "D.class" in your jar "myjar.jar" (B/C/D.class)
2. Why is this particular requirement of putting D.class in B/C/D.class directory structure in "myjar.jar". Why can't you just create a jar "myjar.jar" and put "D.class" there?
3. Have you tried this yourself?

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: question reg jar file
 
Similar Threads
chapter 10 question number 11 k&b book (on jar files)
How to execute jar file from another directory
Confusion over java classpath
Question related to self test question in SCJP (Sierra/Bates) Java 6 book
Questions about classpath on SCJP book.