Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

errors with the command line compiler

 
J. Kevin Robbins
Bartender
Pie
Posts: 1801
28
Chrome Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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/BeerTest.java

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

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

No matter what I try, I get this:
src\com\example\model\BeerTest.java:13: 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?

Thanks!
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

Use just

-classpath classes

or

-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.

 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
J. Kevin Robbins
Bartender
Pie
Posts: 1801
28
Chrome Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Doh! Working! Thanks for the help, and thanks for the tip on the code tags.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic