| Author |
Directory structure for a file in a package
|
J C upadhyay
Greenhorn
Joined: Nov 24, 2011
Posts: 16
|
|
Hi,
I came across a drag and drop question that asks to create a directory structure. The question states: There is a file Zip.java as shown
package w.x;
import w.y.Zoom;
public class Zip{
public static void main(String[] args){
new Zoom().doStuff();
}
}
w.y.Zoom has been compiled and deployed into a JAR file w.jar
The program compiles with the command from the $ROOT
javac -cp w.jar -d . Zip.java
The question asks to create a directory structure and the answer is:
$ROOT
|---------Zip.java
|---------w.jar
|--------w
|----y
|-------Zoom.class
In my opinion Zip.java compiles fine only if the first statement 'package w.x' is commented. With the package statement in place, Zip.java should be saved inside the directory w/x
|
 |
John Jai
Bartender
Joined: May 31, 2011
Posts: 1776
|
|
All the files listed looks like present only under the ROOT directory. I think there is some formatting issue in your post.
In my opinion Zip.java compiles fine only if the first statement 'package w.x' is commented. With the package statement in place, Zip.java should be saved inside the directory w/x
No need - for compilation the package structure is not checked.. only while running the Zip class.
|
 |
J C upadhyay
Greenhorn
Joined: Nov 24, 2011
Posts: 16
|
|
Hi John,
I am sorry for that.
I wonder why the directory structure changes when i post, all the pipes shift to the leftmost side. The answer is:
$ROOT
|
|-------[w.jar]-------w-------y-------Zoom.class
|
|-------Zip.java
$ROOT
|
|-------[w.jar]
|-------w-------y-------Zoom.class
|-------w-------x-------Zip.java
However, in this case, the command to compile Zip.java should be
$ROOT>javac -cp w.jar w.x.Zip.java
|
 |
 |
|
|
subject: Directory structure for a file in a package
|
|
|