| Author |
packages
|
Asanka Vithanage
Ranch Hand
Joined: Oct 24, 2008
Posts: 59
|
|
hai ranchers i want compile and run follwing codes please give me the step by step procedure //this code in the folder desktop/B file name X.java package SD; public class X{ public static void main(String as[]){ System.out.println("B"); } } //this code in the folder desktop/A file name Y.java import SD.x; class Y{ public static void main(String as[]){ System.out.println("A"); } } i use followig code but it's not working(i am in the desktop prompt) javac -classpath B/X.java A/Y.java tells package SD does not exit
|
SCJP 1.5 (94%)
|
 |
Ganeshkumar cheekati
Ranch Hand
Joined: Oct 13, 2008
Posts: 362
|
|
Hi asanka.... In the first code your class name is X. but in second code you have used import SD.x; instead of import SD.X; now it compiles fine....
|
SCJP5 and SCWCD1.5
Think Twice Act Wise...
|
 |
Asanka Vithanage
Ranch Hand
Joined: Oct 24, 2008
Posts: 59
|
|
hai I corrected the code still it is gives above error if You can put the correct commands to compile and run the above code it would be help full to me.
|
 |
Ganeshkumar cheekati
Ranch Hand
Joined: Oct 13, 2008
Posts: 362
|
|
|
can you tell me the command you have used to compile your class X?
|
 |
M Srilatha
Ranch Hand
Joined: Aug 27, 2008
Posts: 137
|
|
Hi asanka... As you are declaring a package name SD for class X, you have to place the X.java file under SD folder. Create a folder "SD" inside "B" and then compile class X using the following command: javac B\SD\X.java and compile Y.java using javac -classpath B A\Y.java It should work! Hope this helps!
|
Thanks,<br />Srilatha M
|
 |
Asanka Vithanage
Ranch Hand
Joined: Oct 24, 2008
Posts: 59
|
|
Thank you it is working now i want to run this x and y files how can i do this please send me the command i want to run from C:\Users\User\Desktop i have set classpatn to difeerent folder using Environment variable so it is possible run x and y without changinhg it in current prompt(C:\Users\User\Desktop)
|
 |
M Srilatha
Ranch Hand
Joined: Aug 27, 2008
Posts: 137
|
|
Try using the following commands: java -classpath B SD/X java -classpath B;A Y
|
 |
Asanka Vithanage
Ranch Hand
Joined: Oct 24, 2008
Posts: 59
|
|
i caught it finally after hard practicing thank you for you,r support
|
 |
 |
|
|
subject: packages
|
|
|