SCJP 6
Q2)2. Secondly, if you have the package in D: drive as "d:\p\a.class"
where "p" is the package name. Then from command line we can execute the a.class using the fully qualified name of the class which is "p.a"
F:\>java -cp D:\ p.a
or you can set D:\ in the classpath environment variable and say
F:\>java p.a
Is this method right???
This is not working for me though i use cp option
can any one say how to use cp option for the above example
and how to set the classpath for the above example
D:\>javac -d . a.java //compiled with this command
F:\>java -cp D:\ p.a
hello I am a
F:\>set classpath=%classpath%;D:\
F:\>java p.a
hello I am a
SCJP 6
q3) saved under a.java
package p;
public class a
{
public static void main(String [] args )
{
System.out.println("asdf");
}
}
typed at the command prompt e:\> javac -d . a.java
then i got a.class under p folder as p/a.class
how to see the output when iam in e: itself
i typed like this e:cd p
then e:\p> java a
but i am unable to see the output ? what should be the command to see the output ?
SCJP 6
q4) I also went into f: and used cp option as
f:\ java -cp e:\p.a
IT IS NOT getting .iam unable to see the output ???
SCJP 6
Q5) If i have a jar file in d: \jars . which consists of packages then how would i use that in different directory say e:
and access the package in d:\jars\package...how to set classpath for jars across drives and access the packages in that jar ?
what should be the commands for the above 5 questions ? dear ranchers what could be the solutions for these?
E:\>jar -cvf hans.jar packag
added manifest
adding: packag/(in = 0) (out= 0)(stored 0%)
adding: packag/pack/(in = 0) (out= 0)(stored 0%)
adding: packag/pack/sri/(in = 0) (out= 0)(stored 0%)
adding: packag/pack/sri/poi/(in = 0) (out= 0)(stored 0%)
adding: packag/pack/sri/poi/kjdsf/(in = 0) (out= 0)(stored 0%)
adding: packag/pack/sri/poi/kjdsf/sri.class(in = 361) (out= 269)(deflated 25%)
F:\>set classpath=%classpath%;D:\hans.jar
F:\>javac kanth.java
F:\>java kanth
yes
no
F:\>javac -cp D:\hans.jar kanth.java
F:\>java -cp D:\hans.jar;. kanth
yes
no
SCJP 6
Punit Singh wrote:If you use code, your question will look quite beautiful, do not you feel so, see now my answers.
For 1) question you need to set
Do not set e:\packag, as you have imported
So compiler will start finding packag.pack.sri.poi.kjdsf.sri; in e:\packag, that is not there.
SCJP 6
Consider Paul's rocket mass heater. |