Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using Javac Command Line Options in Windows

 
Lindsay Fester
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm wondering about how to use javac command options in the windows command line. I've looked up several tutorials, including Oracle's. I want to be able to create a batch file that finds the source code in one folder and places the compiled classes in another.

What I can enter without a usage error:



What I try to enter, but get a usage error:



Can anyone shed some light on this issue?
 
Jelle Klap
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The javac documentation contains a section that describes exatcly this in some detail. Have a look at the examples posted there, especially the one under heading 'Separating Source Files and Class Files'. It's hard to give any useful suggestions specific to your situation without knowing more about the error message and the directory sctructure.

On a related note, you said you're looking to script the javac call in a batch (.bat) file. I suggest you have a look at Apache ANT instead.
 
Lindsay Fester
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My instructor is offering bonus marks if we "Deliver your project so it can be built with ant". I can't believe I hadn't even though of using an ANT script; I'll definitely look into that.

In the meantime, why won't my batch file work?

I'm in the current directory, which contains:

"src\beans"
"classes\beans"

Beans is the package name. The package beans under the src directory, contains my .java files. The package beans under classes is empty. I want to compile those .java files (in src\beans) and put all the .class files in the "classes\beans" package.

Thanks for the input so far!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic