File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Command line invocation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Command line invocation" Watch "Command line invocation" New topic
Author

Command line invocation

Neha Daga
Ranch Hand

Joined: Oct 30, 2009
Posts: 504
Given two files:

a=b.java
c_d.class

Are in the current directory, which command-line invocation(s) could complete without error? (Choose all that apply.)

1.

java -Da=b c_d
2.

java -D a=b c_d
3.

javac -Da=b c_d
4.

javac -D a=b c_d


question is from K&B.

i think the answer should be 2. but its 1. why?

a=b is the name of a java file its not name-value pair for a property.


SCJP 1.6 96%
Nasser Fayeghi Fard
Greenhorn

Joined: Sep 16, 2009
Posts: 20
Neha Daga wrote:
Given two files:

a=b.java
c_d.class

Are in the current directory, which command-line invocation(s) could complete without error? (Choose all that apply.)

1.

java -Da=b c_d
2.

java -D a=b c_d
3.

javac -Da=b c_d
4.

javac -D a=b c_d


question is from K&B.

i think the answer should be 2. but its 1. why?

a=b is the name of a java file its not name-value pair for a property.


Dear Neha,
Note that there must NOT be any space between -D switch and parameter name


SCJP 6.0 (80%), SCWCD (88%)
Now preparing for SCEA-1
Neha Daga
Ranch Hand

Joined: Oct 30, 2009
Posts: 504
thats what I want to know if a=b is a java file, then how java -Da=b c_d is setting a property ?
rohan yadav
Ranch Hand

Joined: Oct 13, 2009
Posts: 156
Neha if you observe all otions carefully you will find that option 1 is correct one,

As you know javac is used for compiling .java files, and
java is used for running .class files.


Now for each option explanation is as follows

1. 1st option is used for running c_d.class file
and we are setting a=b system property.

2. For 2nd option there shouldn't be any space between D and a=b

3 and 4. We can't use javac to compile class files, we use javac to compile .java files

Hopes this will help you in understanding this


Sage of The Monstrous Toad of Mount Myoboku
Neha Daga
Ranch Hand

Joined: Oct 30, 2009
Posts: 504
yes, now I get it.

thanks Rohan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Command line invocation