aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes javac syntax question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "javac syntax question" Watch "javac syntax question" New topic
Author

javac syntax question

Joe Allen
Ranch Hand

Joined: Nov 14, 2012
Posts: 93
In K&B SCJP 6 book, page 790, it says compiling with javac using the syntax "javac [options] [source files]". Can we switch the positions of [options] with [source files] like the following example does?

The example:
$Root
|-- Light.java
|-- Dark.java
|-- checker
|-- dira
|-- dirb

From $Root:
javac Light.java -cp checker/dira -d checker/dirb


Light.java file is:

package ec.ram;
public class Light{}
class Burn{}


"There are no dumb questions" quoted from HFSJ. "To err is human; to forgive is divine"
OCPJP 6, OCEJWCD 6
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18138
    
  39

Joe Allen wrote:In K&B SCJP 6 book, page 790, it says compiling with javac using the syntax "javac [options] [source files]". Can we switch the positions of [options] with [source files] like the following example does?

The example:
$Root
|-- Light.java
|-- Dark.java
|-- checker
|-- dira
|-- dirb

From $Root:
javac Light.java -cp checker/dira -d checker/dirb


Light.java file is:

package ec.ram;
public class Light{}
class Burn{}



And what happened when you tried it ??

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Joe Allen
Ranch Hand

Joined: Nov 14, 2012
Posts: 93
Henry,
Thanks for replying. I tried it, and it worked, but I am not confident about it, because K&B book does not mention it. That is why I posted it here to get confirmation. So does it mean that we can also use the syntax of "javac [source files] [options]"? Somehow somewhere in a mock exam(maybe in K&B book), there was a test item that made it wrong to switch [options] with [source files] , if I remember it right.
Joe Allen
Ranch Hand

Joined: Nov 14, 2012
Posts: 93
In K&B book, there are test items for java command syntax, not javac, in which the positions of [options] and the others are not interchaneable.

confirmed through Oracle web site that in javac [source files] [options] syntax, positions of [source files] and [options] are interchangeable. See the link
http://docs.oracle.com/javase/1.5.0/docs/tooldocs/windows/javac.html
Venugopal Reddy Gangireddy
Greenhorn

Joined: Feb 26, 2013
Posts: 1

Joe Allen wrote:In K&B book, there are test items for java command syntax, not javac, in which the positions of [options] and the others are not interchaneable.

confirmed through Oracle web site that in javac [source files] [options] syntax, positions of [source files] and [options] are interchangeable. See the link
http://docs.oracle.com/javase/1.5.0/docs/tooldocs/windows/javac.html


Thanks Joe

Everything is clear now
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: javac syntax question
 
Similar Threads
Packages
doubt in classpath
classpath
Relative and Absolute Paths
classpath.