• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

javac syntax question

 
Joe Allen
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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{}

 
Henry Wong
author
Marshal
Pie
Posts: 21422
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Joe Allen
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
IntelliJ IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic