Sponsored Link •
|
Advertisement
|
Advertisement
|
This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.
Message:
Hello /////////////Test.java starts here We have mentioned that the package for the class Test is pack.spack. It means the class file Test.class ( Test.class will be created when you compile the Test.java file) will be placed in a folder ...\pack\spack . So, the Test.class' location will look like: ...\pack\spack\Test.class . If your pack had been myPackage then yout Test.class would have been expected to be in a folder like: ...\myPackage\Test.class. However, it doesn't say anything about the location of the folder pack. It could be anywhere on your system. So, you can create a folder and place your Test.class anywhere in you PC. Some of the possible location for your Test.class would be: c:\pack\spack\Test.class, c:\programs\pack\spack\Test.class or c:\java_programs\pack\spack\Test.class. The part before the pack folder in above path is taken from CLASSPATH environment variable you set on your PC. So, if your location of class file is c:\pack\spack\Test.class then your classpath should must include the folder c:\ as: You may not want to set ant classpath at all. In that case you need to pass classpath value when you want to run the class. When you put your class Test in pack.spack package then the fully qualified name of your class is pack.spack.Test and not just Test. So, at the time of running the class you need to mention this name . I suppose that you have placed your Test.java in c:\pack\spack\Test.java and you are running windows. Go to DOS prompt and type in following commands to compile and run it. To run it To run the class you don't have to be in c:\pack\spack folder. You can run it from anywhere. To compile it if you are not in spack folder then you need to specify the full path as: Thanks
Replies: |
Sponsored Links
|