File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes errors with the command line compiler Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "errors with the command line compiler" Watch "errors with the command line compiler" New topic

errors with the command line compiler

J. Kevin Robbins

Joined: Dec 16, 2010
Posts: 1523

I'm working my way through Servlets and JSP and having trouble with the command line compiler. If I move all my files into an eclipse project everything compiles and runs, so it's apparently the compiler switches that I'm using. I don't want to rely on eclipse; I want to learn this from the command line, but this is getting frustrating.

The dev environment folders are setup just like the book. The BeerExpert class compiles fine, but my BeerTest code won't compile. It's in the same folder as the BeerExpert class and I've tried all these compiler commands. (plus a few others, out of desperation)

C:\MyProjects\beerV1>javac -classpath . -d classes src/com/example/model/

C:\MyProjects\beerV1>javac -classpath c:\myprojects\beerv1\classes\com\example\model\ -d classes src/com/example/model/

C:\MyProjects\beerV1>javac -classpath classes/com/example/model/BeerExpert.class -d classes src/com/example/model/

No matter what I try, I get this:
src\com\example\model\ cannot find symbol
symbol : class BeerExpert
location: class com.example.model.BeerTest
BeerExpert expert = new BeerExpert();

Why can't my test class find the BeerExpert class? Like I said, it works in eclipse.

Here's the BeerTest code

I know this is probably obvious to someone and I'll kick myself when I see the solution. Help please?


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." -- Ted Nelson
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199


Welcome to JavaRanch!

Use just

-classpath classes


-classpath c:\myprojects\beerv1\classes

The classpath is where the compiler should find the roots of the directory trees holding the classes, not the class files themselves. The classpath indicates where the "com" directory might be found.

[Jess in Action][AskingGoodQuestions]
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

Hi and welcome to the Javaranch.

Please UseCodeTags when posting code. It will highlight your code and make it much easier to read. It probably will also increase the number of people helping you. You can edit your post with the button.

"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
J. Kevin Robbins

Joined: Dec 16, 2010
Posts: 1523

Doh! Working! Thanks for the help, and thanks for the tip on the code tags.

I agree. Here's the link:
subject: errors with the command line compiler
It's not a secret anymore!