Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Beginning Java and the fly likes Using the '-d' flag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Using the Watch "Using the New topic
Author

Using the '-d' flag

Marcus Deviln
Ranch Hand

Joined: Jan 29, 2009
Posts: 39
I'm trying to put the .class files into a new folder I've made just for that purpose using the -d flag.

c:\Users\Marcus\My Documents>javac -d \bytecode
javac: directory not found: \bytecode
Usage: javac <options> <source files>
use -help for a list of possible options

c:\Users\Marcus\My Documents>javac -d ..\bytecode c:\Users\Marcus\My Documents\J
unk.java
javac: invalid flag: c:\Users\Marcus\My
Usage: javac <options> <source files>
use -help for a list of possible options

I tried a lot of other command possibilities besides these but none are working. What is it I am missing? I'm referring to chapter 10, page 792, Development of Kathy and Berts SCJP study guide


+Deviln+ The power of JAVA compels you!
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

-d is used to tell the compiler where to generate .class files. You still need to tell him which file you want to compile. For example, javac -d classes src/Hello.java

The second error is because you have spaces in your path. Use double-quotations to solve it :
javac -d ..\bytecode "c:\Users\Marcus\My Documents\Junk.java"


[My Blog]
All roads lead to JavaRanch
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

And the first command you tried was trying to put the class files into c:\bytecode, and while it's *possible* that's what you wanted, I'm skeptical.
Marcus Deviln
Ranch Hand

Joined: Jan 29, 2009
Posts: 39
Ah Ha!! Chris that worked. TOTALLY ROCKIN!! Thank you so much for your time
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

You're welcome
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using the '-d' flag
 
Similar Threads
errors with main class
Invalid Flag Error when using javac
Compiling java files
Compiling a Servlet
Compiler