• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

errors with the command line compiler

 
Bartender
Posts: 1810
28
jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 1810
28
jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Doh! Working! Thanks for the help, and thanks for the tip on the code tags.

 
reply
    Bookmark Topic Watch Topic
  • New Topic